vimuth
vimuth

Reputation: 5602

How to hide labels in a form class in symfony4?

is there a way to hide label from form field in symfony 4?. This is my coding.

          $builder
                ->add('min', TextType::class, array('attr' => array(
                        'class' => 'min date',
                        'label' => false,
                        'required' => false,
                        'id' => 'min')))
                ->add('max', TextType::class, array('attr' => array(
                        'class' => 'max date',
                        'label' => false,
                        'id' => 'max'))); 

Even though I added 'label' => false, label still appears.

Upvotes: 0

Views: 1517

Answers (1)

Dirk J. Faber
Dirk J. Faber

Reputation: 4691

You have put in in the array of attr where it does not belong. This works:

$builder
    ->add('min', TextType::class, array(
        'label' => false,
        'attr' => array(
            'class' => 'min date',
            'required' => false,
            'id' => 'min')))
    ->add('max', TextType::class, array(
        'label' => false,
        'attr' => array(
            'class' => 'max date',
            'id' => 'max')));

Upvotes: 1

Related Questions