| @@ 9-45 (lines=37) @@ | ||
| 6 | use steevanb\SymfonyFormOptionsBuilder\Behavior\OptionAccessorsTrait; |
|
| 7 | use Symfony\Component\Form\Extension\Core\Type\PercentType; |
|
| 8 | ||
| 9 | class PercentOptionsBuilder extends AbstractOptionsBuilder |
|
| 10 | { |
|
| 11 | use OptionAccessorsTrait; |
|
| 12 | use Behavior\ScaleTrait; |
|
| 13 | use Behavior\AttrPlaceHolderTrait; |
|
| 14 | use Behavior\AutofocusTrait; |
|
| 15 | use Behavior\AutocompleteTrait; |
|
| 16 | ||
| 17 | const TYPE_FRACTIONAL = 'fractional'; |
|
| 18 | const TYPE_INTEGER = 'integer'; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * @return string |
|
| 22 | */ |
|
| 23 | public static function getBuilderType() |
|
| 24 | { |
|
| 25 | return PercentType::class; |
|
| 26 | } |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @param string $type Use self::TYPE_XXX |
|
| 30 | * @return $this |
|
| 31 | * @link http://symfony.com/doc/current/reference/forms/types/percent.html#type |
|
| 32 | */ |
|
| 33 | public function setType($type) |
|
| 34 | { |
|
| 35 | return $this->setOption('type', $type); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @return string |
|
| 40 | */ |
|
| 41 | public function getType() |
|
| 42 | { |
|
| 43 | return $this->getOption('type'); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| @@ 9-45 (lines=37) @@ | ||
| 6 | use steevanb\SymfonyFormOptionsBuilder\Behavior\OptionAccessorsTrait; |
|
| 7 | use Symfony\Component\Form\Extension\Core\Type\UrlType; |
|
| 8 | ||
| 9 | class UrlOptionsBuilder extends AbstractOptionsBuilder |
|
| 10 | { |
|
| 11 | use OptionAccessorsTrait; |
|
| 12 | use Behavior\AttrPlaceHolderTrait; |
|
| 13 | use Behavior\AutofocusTrait; |
|
| 14 | use Behavior\AutocompleteTrait; |
|
| 15 | ||
| 16 | const PROTOCOL_HTTP = 'http'; |
|
| 17 | const PROTOCOL_HTTPS = 'https'; |
|
| 18 | const PROTOCOL_FTP = 'ftp'; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * @return string |
|
| 22 | */ |
|
| 23 | public static function getBuilderType() |
|
| 24 | { |
|
| 25 | return UrlType::class; |
|
| 26 | } |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @param mixed $protocol |
|
| 30 | * @return $this |
|
| 31 | * @link http://symfony.com/doc/current/reference/forms/types/url.html#default-protocol |
|
| 32 | */ |
|
| 33 | public function setDefaultProtocol($protocol) |
|
| 34 | { |
|
| 35 | return $this->setOption('default_protocol', $protocol); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @return mixed |
|
| 40 | */ |
|
| 41 | public function getDefaultProtocol() |
|
| 42 | { |
|
| 43 | return $this->getOption('default_protocol'); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||