I'm building a questionnaire that is shown in two templates but I need to not show some filed in one of the templates
$builder
->add('acceptConsent', CheckboxType::class, [
'label_attr' => [
'class' => 'font-weight-bold'
],
'required' => true,
'constraints' => new NotBlank(),
'disabled' => $readOnly,
])
there is any way to set the form to not render a field?
CodePudding user response:
You may "just" not render your form_row
or form_widget
And close your form this way {{ form_end(form, {'render_rest': false}) }}
So that unrendered fields a not rendered.
Have a look here for more infos: https://symfony.com/doc/current/form/form_customization.html