In my Symfony 4 form, I am try to get a placeholder for my input. I tried the below but I get an error that it is 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 below, here I am not getting an error, just nothing is rendering.
$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