This is how i currently activate errors on my forms:
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('title', null, array('error_bubbling' => true))
->add('content', null, array('error_bubbling' => true))
;
}
Is there a form-wide version?
No. In general you dont need to make errors bubble to parent form. If you want to display all errors in one place, you can do this in the template.
If you are using the form types correctly (maybe don't let symfony guess it) then you should get error bubbling by default as seen here:
http://symfony.com/doc/current/reference/forms/types/text.html#error-bubbling
However If you are using a custom form type then you can set the default error_bubbling by default with configureOptions
final class CustomFormType extends AbstractType
{
/** {@inheritdoc} */
public function buildForm(FormBuilderInterface $builder, array $options)
{
...
}
/** {@inheritdoc} */
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired('label');
$resolver->setDefaults([
'error_bubbling' => false,
'compound' => true,
]);
}
}
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