Closed
Description
Symfony version(s) affected: 4.1
Description
When moving from 4.0.11 to 4.1 Twig returns an error Variable "help" does not exist
This error is triggered on the form templates. This error appears when using bootstrap, foundation 5 and the default layout.
How to reproduce
Create a simple form using the FormBuilder:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email', EmailType::class, array (
'label' => 'user.form.email'
))
->add('username', TextType::class, array (
'label' => 'user.form.username'
))
->add('plainPassword', RepeatedType::class, array(
'type' => PasswordType::class,
'options' => array(
'translation_domain' => 'User',
'attr' => array(
'class' => 'edit-optional-password'
)
),
'first_options' => array('label' => 'user.form.password'),
'second_options' => array('label' => 'user.form.password_confirmation'),
'invalid_message' => 'user.password.mismatch',
'attr' => array(
'data-del' => 'del'
)
))
->add('register', SubmitType::class, array (
'label' => 'user.form.register.button'
));
}
Possible Solution
For example in the file vendor/symfony/symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig
Line 262 and Line 300
From : {%- if help is not empty -%}
To: {%- if help is defined and help is not empty -%}
Additional context