Custom rendering of a “repeated” field from Symfony 2 in Twig

前端 未结 5 1730
南旧
南旧 2020-12-23 20:56

I just started using Twig and I\'m trying to build a registration form. To add a password/re-enter password field I use the \"repeated\" filetype:

->add(\         


        
5条回答
  •  时光说笑
    2020-12-23 21:23

    If you want to seperate both passwords field from a repeated method in your twig template you just have to call back their respective names like:

    {{ form_label(form.password.pass, "Password :") }}
    {{ form_widget(form.password.pass) }}
    
    {{ form_label(form.password.confirm, "Confirm :") }}
    {{ form_widget(form.password.confirm) }}
    

    And of course in your function:

    /..
    ->add('password', 'repeated', array(
    'first_name' => 'pass',
    'second_name' => 'confirm',
    'type' => 'password'
    ))
    

    Regards.

提交回复
热议问题