Closed
Description
Hi!
Symfony version(s) affected: 5.2.1
Description
When i'm trying to use the new form helpers https://symfony.com/blog/new-in-symfony-5-2-form-field-helpers (btw why does this show an unsupported message?) I get a type exception:
Return value of Symfony\Bridge\Twig\Extension\FormExtension::createFieldTranslation() must be of the type string, null returned
How to reproduce
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, ['empty_data' => ''])
->add('locked', CheckboxType::class);
}
}
{{ form_start(form) }}
<div class="form-group row">
<label class="col-form-label col-md-3 col-lg-2">{{ field_label(form.locked) }}</label>
<div class="col-form-widget col-md-9 col-lg-6">
{{ form_widget(form.locked) }}
{{ form_errors(form.locked) }}
</div>
</div>
{{ form_end(form) }}
Possible Solution
maybe allow return null in referenced function ant the ones that calling it.
https://github.com/symfony/symfony/blob/5.x/src/Symfony/Bridge/Twig/Extension/FormExtension.php#L167
since it can return null, if the first if statement is true.
cheers