These parameters are passed to the field type, in your case formObjectType . Thus, it really depends on what options are used in this area. For example, say you want to pass an option to show the formObjectType display or an formObjectType field. You can do something like this:
// Application/AcmeBundle/Form/Type/FormObjectType.php class FormObjectType extends AbstractType { public function buildForm(FormBuilder $builder, array $options) { $this->add('name', 'text'); if ($options['display_custom_field'] === true) { $this->add('name_custom', 'text'); } } public function getDefaultOptions(array $options) { return array( 'display_custom_field' => false, ); } } // Application/AcmeBundle/Controller/FormController.php class FormController extends Controller { public function createForm($object) { return $this->getFormFactory()->create(new FormObjectType(), $object, array( 'display_custom_field' => true, )); } public function customAction() { $form = $this->createForm(); // Code here ... } }
If the parameter is an array, passed or missing array is passed at all, the default value is set to formObjectType . Thus, this array is used to configure the parameters expected from this type. This also works with a built-in type like text , date , etc.
Hope this helps.
Yours faithfully,
Matt
PS You must start your class name with an uppercase letter: formObjectType instead of formObjectType to distinguish variables and methods from class names. This is just a suggestion :)
source share