Reputation: 1160
I am working on a project based on Symfony 2.7.
I have added the following function a custom form type:
public function setDefaultOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'error_bubbling' => true
]
);
}
... and when loading the form, I now get the following FatalErrorException:
Compile Error: Declaration of MyCompany\AppBundle\Form\ContactType::setDefaultOptions() must be compatible with Symfony\Component\Form\FormTypeInterface::setDefaultOptions(Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver)
Glancing at FormTypeInterface::setDefaultOptions()
, it appears that I am complying with the method signature. What am I doing wrong?
Upvotes: 1
Views: 934
Reputation: 15247
You can either type $resolver
correctly, it's expected to be OptionsResolverInterface
, not OptionsResolver
.
Or, better to replace setDefaultOptions(OptionsResolverInterface $resolver)
by configureOptions(OptionsResolver $resolver)
since it's deprecated in Symfony 2.7 source
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'error_bubbling' => true
]
);
}
Upvotes: 4