123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- Form field definition
- =====================
- These fields are used to display inside the edit form.
- Example
- -------
- .. code-block:: php
- <?php
- namespace Bundle\Sonta\NewsBundle\Admin;
- use Bundle\Sonata\BaseApplicationBundle\Admin\Admin;
- class PostAdmin extends Admin
- {
- protected $class = 'Application\Sonata\NewsBundle\Entity\Post';
- protected $formFields = array(
- 'enabled',
- 'title',
- 'abstract',
- 'content',
- 'tags' => array('options' => array('expanded' => true)),
- 'comments_close_at',
- 'comments_enabled',
- 'comments_default_status'
- );
- public function configureFormFields()
- {
- $this->formFields['comments_default_status']->setType('choice');
-
- $options = $this->formFields['comments_default_status']->getOption('form_field_options', array());
- $options['choices'] = Comment::getStatusList();
- $this->formFields['comments_default_status']->setOption('form_field_options', $options);
- }
- }
- Types available
- ---------------
- - array
- - boolean
- - choice
- - datetime
- - decimal
- - integer
- - many_to_many
- - many_to_one
- - one_to_one
- - string
- - text
- if no type is set, the Admin class will use the one set in the doctrine mapping definition.
- Tweak it!
- ---------
- - It is possible to tweak the default template by setting a template key in the
- - If the project required specific behaviors, they can be implemented in the
- configureFormFields() method.
|