如果要覆盖现有的FormType,请遵循该文档: http://symfony.com/doc/master/bundles/FOSUserBundle/overriding_forms.html
如果要在html中选择特定字段,可以选择以下字段:
{{ form_widget(form.email) }}
{{ form_widget(form.username) }}
要么
{{ form_widget(form.email, { 'attr': {'class': 'foo'} }) }}
你可以找到它 vendor/friendsofsymfony/user-bundle/Form/Type/RegistrationFormType.php 如果你想改变它的直接
vendor/friendsofsymfony/user-bundle/Form/Type/RegistrationFormType.php
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', )) ; }
但最好在config.yml中覆盖下面的forme类型(创建一个新的formType)
fos_user: # ... registration: form: type: AppBundle\Form\RegistrationType