In a Symfony 4 form, I am trying to get a placeholder on my input. I tried the code below, but I get an error telling me it's not allowed. Any ideas how else I can achieve this?
$builder->add(
'firstname',
TextType::class,
['label' => 'Vorname ', 'placeholder' => 'Your name',]
)
As suggested in the documentation I have also tried the code below, in this case I am not getting an error, but nothing is rendered.
$builder->add(
'firstname',
TextType::class,
['label' => 'Vorname '],
['attr' => ['placeholder' => 'Vorname ']]
)
You need to do like this :
->add('firstname', TextType::class, array(
'label' => 'Vorname ',
'attr' => array(
'placeholder' => 'hereYourPlaceHolder'
)
))
As they say in the documentation