0

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?

1
  • Could you add your twig in order to understand better the issue ? Commented Nov 5, 2021 at 11:03

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.