| @@ 13-53 (lines=41) @@ | ||
| 10 | * @package Faulancer\Form\Type\Base |
|
| 11 | * @author Florian Knapp <[email protected]> |
|
| 12 | */ |
|
| 13 | class Number extends AbstractType |
|
| 14 | { |
|
| 15 | ||
| 16 | /** @var string */ |
|
| 17 | protected $inputType = 'input'; |
|
| 18 | ||
| 19 | /** @var string */ |
|
| 20 | protected $element = ''; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @return self |
|
| 24 | */ |
|
| 25 | public function create() |
|
| 26 | { |
|
| 27 | parent::create(); |
|
| 28 | ||
| 29 | $output = '<' . $this->inputType; |
|
| 30 | ||
| 31 | foreach ($this->definition['attributes'] as $attr => $value) { |
|
| 32 | ||
| 33 | if (!empty($this->getValue()) && $attr === 'value') { |
|
| 34 | continue; |
|
| 35 | } |
|
| 36 | ||
| 37 | $output .= ' ' . $attr . '="' . $value . '" '; |
|
| 38 | ||
| 39 | } |
|
| 40 | ||
| 41 | if (!empty($this->getValue())) { |
|
| 42 | $output .= ' value="' . $this->getValue() . '"'; |
|
| 43 | } |
|
| 44 | ||
| 45 | $output .= '/>'; |
|
| 46 | ||
| 47 | $this->element = $output; |
|
| 48 | ||
| 49 | return $this; |
|
| 50 | } |
|
| 51 | ||
| 52 | } |
|
| @@ 13-51 (lines=39) @@ | ||
| 10 | * @package Form\Type\Base |
|
| 11 | * @author Florian Knapp <[email protected]> |
|
| 12 | */ |
|
| 13 | class Tel extends AbstractType |
|
| 14 | { |
|
| 15 | /** @var string */ |
|
| 16 | protected $inputType = 'input'; |
|
| 17 | ||
| 18 | /** @var string */ |
|
| 19 | protected $element = ''; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @return self |
|
| 23 | */ |
|
| 24 | public function create() |
|
| 25 | { |
|
| 26 | parent::create(); |
|
| 27 | ||
| 28 | $output = '<' . $this->inputType; |
|
| 29 | ||
| 30 | foreach ($this->definition['attributes'] as $attr => $value) { |
|
| 31 | ||
| 32 | if (!empty($this->getValue()) && $attr === 'value') { |
|
| 33 | continue; |
|
| 34 | } |
|
| 35 | ||
| 36 | $output .= ' ' . $attr . '="' . $value . '" '; |
|
| 37 | ||
| 38 | } |
|
| 39 | ||
| 40 | if (!empty($this->getValue())) { |
|
| 41 | $output .= ' value="' . $this->getValue() . '"'; |
|
| 42 | } |
|
| 43 | ||
| 44 | $output .= '/>'; |
|
| 45 | ||
| 46 | $this->element = $output; |
|
| 47 | ||
| 48 | return $this; |
|
| 49 | } |
|
| 50 | } |
|