php - How to not display label from password field in Twig -
currently, work registratio form of forum...
when use {{ form_widget(form.plainpassword }}
in twig view get:
<div> <label for="fos_user_registration_form_plainpassword_first" class="required">first</label> <input id="fos_user_registration_form_plainpassword_first" name="fos_user_registration_form[plainpassword][first]" required="required" type="password"> </div> <div> <label for="fos_user_registration_form_plainpassword_second" class="required">second</label> <input id="fos_user_registration_form_plainpassword_second" name="fos_user_registration_form[plainpassword][second]" required="required" type="password"> </div>
registrationformtype.php
class registrationformtype extends abstracttype { private $class; /** * @param string $class user class name */ public function __construct($class) { $this->class = $class; } public function buildform(formbuilderinterface $builder, array $options) { $builder ->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'fosuserbundle')) ->add('username', null, array('label' => 'form.username', 'translation_domain' => 'fosuserbundle')) ->add('plainpassword', 'repeated', array( 'type' => 'password', 'options' => array('translation_domain' => 'fosuserbundle'), //'first_options' => array('label' => 'form.password'), //'second_options' => array('label' => 'form.password_confirmation'), 'invalid_message' => 'fos_user.password.mismatch', )) ; } public function configureoptions(optionsresolver $resolver) { $resolver->setdefaults(array( 'data_class' => $this->class, 'intention' => 'registration', )); } // bc sf < 2.7 public function setdefaultoptions(optionsresolverinterface $resolver) { $this->configureoptions($resolver); } public function getname() { return 'bissap_user_registration'; } }
usualy, when use form_widget
, label not display form builder configuration label still in form.
in fact, password
field combinaison of 2 fields : first
, second
form_widget password = 2 x ( form_row input )
instead of code with
{{ form_widget(form.plainpassword }}
just change by
{{ form_widget(form.plainpassword.first }} {{ form_widget(form.plainpassword.second }}
Comments
Post a Comment