How to add a shortcut to the form designer (and not to the twig)?

I have this code, but it does not work:

$builder->add('name','text',array( 'label' => 'Due Date', )); 

the problem i have in fosuserbundle is i have top form

 <?php namespace Acme\UserBundle\Form\Type; use Symfony\Component\Form\FormBuilder; use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType; class RegistrationFormType extends BaseType { public function buildForm(FormBuilder $builder, array $options) { // add your custom field $builder->add('name','text',array( 'label' => 'Due Date', )); parent::buildForm($builder, $options); } public function getName() { return 'acme_user_registration'; } } 

but it doesnโ€™t work, do not give me any errors and set the label "fos_user_registration_form_name"

+4
source share
1 answer

You see the label as fos_user_registration_form_name , because FOSUserBundle uses translation files to translate all texts into it.

You must add your translations to a file called Resources/translations/FOSUserBundle.nb.yml (example for Norwegian), or you can change the translation file that comes with the package (it is best to copy it to Acme\UserBundle ).

+5
source

Source: https://habr.com/ru/post/1397344/


All Articles