Home > Software engineering >  symfony 5 form type define the labels
symfony 5 form type define the labels

Time:05-15

I created the CRUD for my entity and I need to somehow define the labels for the fields of the entity.

I can define them in the form type, for example:

$builder
    ->add('name' , null, [
        'attr' => ['autofocus' => true],
        'label' => 'Product name',
    ])

but I don't think this is the best solution.

Which is the best approach?

Do I have to use translations, even if the app is single language?

Is there any other solution?

CodePudding user response:

Yes is this the best practies, in official documentation explained here https://symfony.com/doc/current/reference/forms/types/form.html#label-translation-parameters

  • Related