| 1 |
<?php |
| 2 |
|
| 3 |
namespace ipl\Html\FormElement; |
| 4 |
|
| 5 |
use ipl\Html\Attribute; |
| 6 |
use ipl\Html\Contract\FormSubmitElement; |
| 7 |
|
| 8 |
class SubmitElement extends InputElement implements FormSubmitElement |
| 9 |
{ |
| 10 |
protected $type = 'submit'; |
| 11 |
|
| 12 |
protected $buttonLabel; |
| 13 |
|
| 14 |
public function setLabel($label) |
| 15 |
{ |
| 16 |
$this->buttonLabel = $label; |
| 17 |
|
| 18 |
return $this; |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* @return string |
| 23 |
*/ |
| 24 |
public function getButtonLabel() |
| 25 |
{ |
| 26 |
if ($this->buttonLabel === null) { |
| 27 |
return $this->getName(); |
| 28 |
} else { |
| 29 |
return $this->buttonLabel; |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* @return mixed|static |
| 35 |
*/ |
| 36 |
public function getValueAttribute() |
| 37 |
{ |
| 38 |
return new Attribute('value', $this->getButtonLabel()); |
| 39 |
} |
| 40 |
|
| 41 |
public function hasBeenPressed() |
| 42 |
{ |
| 43 |
return $this->getButtonLabel() === $this->getValue(); |
| 44 |
} |
| 45 |
|
| 46 |
public function isIgnored() |
| 47 |
{ |
| 48 |
return true; |
| 49 |
} |
| 50 |
} |