I have a symfony 3.4 form class UserForm and I set the option 'password_field' => false in the setDefaultOptions method:
public function setDefaultOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => User::class,
'password_field' => false,
));
}
In my controller where I'm using this form, I set the option:
$form = $this->createForm(UserForm::class, $user, [
'password_field' => false,
]);
By loading the form in the browser, I get the following error message:
The option "password_field" does not exist. Defined options are: "action", "allow_extra_fields", "attr", "auto_initialize", "block_name", "by_reference", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "inherit_data", "invalid_message", "invalid_message_parameters", "label", "label_attr", "label_format", "mapped", "method", "post_max_size_message", "property_path", "required", "translation_domain", "trim", "upload_max_size_message", "validation_groups".
Everything looks right to me, as described in the documentation. Any ideas?
setDefaultOptions() has been deprecated in favor of configureOptions(). This method name was used in Symfony 2.x
See UPGRADE-3.0.md.
configureOptions() is already used in Symfony 3.x
So you have to replace method names ;)
Example:
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => User::class,
'password_field' => false
]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With