I have looked through the documentation and unless i’ve missed it I’m not able to find anything explaining what the official $options are for the buildForm->add() function in Symfony2.
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('fieldname1');
$builder->add('fieldname2', new formObjectType(), $arrayOptions);
}
Taking the code above, what options would be passed in as an array for the second field.
Thanks
This same question has bothered me as well. The default options are written inside respective type classes. Let’s take
DateTypeas an example.DateType::getDefaultOptions()lists all the default options, if you don’t define them yourself. In addition we haveDateType::getAllowedOptionValues()– it seems to define which values are valid for certain options.Note that all of the classes extend
AbstractTypeand in addition to this inheritance every “type” implementsFormTypeInterface::getParent(). ForDateTypethe parent isFieldType.FieldTypeis obviously the parent class for most fields and it has a couple of default options defined as well. I’m guessing all these options get merged together upon calling out a specific form type.