2016-04-02 5 views
1

Ich möchte ein einzelnes Feldkennwort anstelle eines Felds "wiederholten" Typs haben.Sf2: Fos UserBundle Registrierungsformular, einzelnes Feldpasswort

Ich übersteuerte den RegistrierungsFormTyp auf diese Weise.

public function buildForm(FormBuilderInterface $builder, array $options) 
{ 
    parent::buildForm($builder, $options); 
    $builder 
     ->remove('username') // email is used as username 
     ->remove('plainPassword') // use only a single field password 
     ->add('firstname') 
     ->add('lastname') 
     ->add('plainPassword', 'password'); 
} 

und ruft es auf diese Weise in meinem Zweig Vorlage

{{ form_widget(form.plainPassword, {'attr': {'class': 'input', 'placeholder': 'Password', 'required': 'required'}}) }} 

Sobald ich das Feld Plain in Form Builder hinzufügen, gibt sie:

Erwartetes Argument vom Typ " string "," array "in Anbieter/symfony/symfony/src/Symfony/Komponente/Validator/Constraints/LengthValidator.php in Zeile 38

Was mache ich falsch? Ich konnte kein Thema zum Überschreiben dieses Feldes finden.

UPDATE:

dump($builder->all()); 

kehrt:

array:4 [▼ 
"email" => FormBuilder {#1037 ▶} 
"firstname" => FormBuilder {#1046 ▶} 
"lastname" => FormBuilder {#1196 ▶} 
"plainPassword" => FormBuilder {#1184 ▼ 
-children: [] 
-unresolvedChildren: [] 
#locked: false 
-dispatcher: EventDispatcher {#1183 ▶} 
-name: "plainPassword" 
-propertyPath: null 
-mapped: true 
-byReference: true 
-inheritData: false 
-compound: false 
-type: ResolvedTypeDataCollectorProxy {#1191 ▶} 
-viewTransformers: [] 
-modelTransformers: [] 
-dataMapper: null 
-required: true 
-disabled: false 
-errorBubbling: false 
-emptyData: Closure {#1185 ▶} 
-attributes: array:5 [▶] 
-data: null 
-dataClass: null 
-dataLocked: false 
-formFactory: FormFactory {#429 ▶} 
-action: "" 
-method: "POST" 
-requestHandler: HttpFoundationRequestHandler {#987 ▶} 
-autoInitialize: true 
-options: array:49 [▼ 
    "block_name" => null 
    "disabled" => false 
    "label" => null 
    "label_format" => null 
    "translation_domain" => null 
    "auto_initialize" => true 
    "trim" => false 
    "required" => true 
    "read_only" => false 
    "max_length" => null 
    "pattern" => null 
    "property_path" => null 
    "mapped" => true 
    "by_reference" => true 
    "virtual" => null 
    "compound" => false 
    "method" => "POST" 
    "action" => "" 
    "post_max_size_message" => "The uploaded file was too large. Please try to upload a smaller file." 
    "error_mapping" => [] 
    "cascade_validation" => false 
    "invalid_message" => "This value is not valid." 
    "invalid_message_parameters" => [] 
    "allow_extra_fields" => false 
    "extra_fields_message" => "This form should not contain extra fields." 
    "csrf_protection" => true 
    "csrf_field_name" => "_token" 
    "csrf_message" => "The CSRF token is invalid. Please try to resubmit the form." 
    "csrf_provider" => CsrfTokenManager {#534 ▶} 
    "intention" => null 
    "sonata_admin" => null 
    "sonata_field_description" => null 
    "label_render" => true 
    "sonata_help" => null 
    "horizontal_label_class" => "" 
    "horizontal_label_offset_class" => "" 
    "horizontal_input_wrapper_class" => "" 
    "description" => "" 
    "always_empty" => true 
    "attr" => [] 
    "data_class" => null 
    "empty_data" => Closure {#1185 ▶} 
    "error_bubbling" => false 
    "label_attr" => [] 
    "inherit_data" => false 
    "validation_groups" => null 
    "constraints" => [] 
    "csrf_token_manager" => CsrfTokenManager {#534 ▶} 
    "csrf_token_id" => null 
] 
} 
] 
+0

Vielleicht ist es ein Cache-Problem, versuchen Sie es zu löschen und versuchen Sie es erneut –

+0

Das änderte nichts. – Brieuc

+0

können Sie einen 'dump ($ builder-> all()); sterben() 'zu sehen, was drin ist –

Antwort

0

ich von 1.3.6 bis 2.0.0-alpha3 FOS Benutzerbündel aktualisiert (aus unterschiedlichen Gründen). Es hat den Fehler behoben.

Verwandte Themen