I am using Form Classes to build the various form in my project.
In the Entity Type file, for the buildForm function, there is a secondary parameter of \"array $options\
Apparently it's not with getDefaultOptions()
anymore, but with setDefaultOptions()
.
Otherwise it says
The option "my_custom_option" does not exist. Known options are: "action", "attr", "auto_initialize", ...
So, for me I had to update setDefaultOptions like this :
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('my_custom_option' => false));
// Others if needed, like in the documentation for : 'data_class' => 'VENDOR\Bundle\Entity\MyEntity', 'csrf_protection' => true
}
And then you can retrieve it in the buildForm
method
public function buildForm(FormBuilderInterface $builder, array $options)
{
$myCustomOption = $options['my_custom_option'];
}