| 1 | <?php |
||
| 13 | class SettingsType extends AbstractType |
||
| 14 | { |
||
| 15 | protected $app; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @param Application $app |
||
| 19 | */ |
||
| 20 | public function __construct($app) |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param FormBuilderInterface $builder |
||
| 27 | * @param $options |
||
| 28 | */ |
||
| 29 | public function buildForm(FormBuilderInterface $builder, array $options) |
||
| 30 | { |
||
| 31 | $builder->add('foo', 'textarea', array( |
||
| 32 | 'label' => 'Foo?', |
||
| 33 | 'required' => false, |
||
| 34 | 'data' => $this->app['settings']['foo'], |
||
| 35 | 'attr' => array( |
||
| 36 | 'data-help-text' => 'Is it really foo?', |
||
| 37 | ), |
||
| 38 | )); |
||
| 39 | |||
| 40 | $builder->add('submitButton', 'submit', array( |
||
| 41 | 'label' => 'Save', |
||
| 42 | 'attr' => array( |
||
| 43 | 'class' => 'btn-primary btn-lg btn-block', |
||
| 44 | ), |
||
| 45 | )); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param OptionsResolverInterface $resolver |
||
| 50 | */ |
||
| 51 | public function setDefaultOptions(OptionsResolverInterface $resolver) |
||
| 52 | { |
||
| 53 | $resolver->setDefaults(array( |
||
| 54 | 'csrf_protection' => true, |
||
| 55 | 'csrf_field_name' => 'csrf_token', |
||
| 56 | )); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | public function getName() |
||
| 66 | } |
||
| 67 |