简体   繁体   中英

Add attributes to the nested field

How can I add attributes to a nested field PasswordType (attribute always_empty )? This code doesn't work:

   $builder
        ->add('password', RepeatedType::class, [
            'type' => PasswordType::class, [
                'always_empty' => false
            ],
            'first_options'  => ['label' => 'Password'],
            'second_options' => ['label' => 'Repeat Password'],
        ])
    ;

It belongs in the 'options' array.

https://symfony.com/doc/current/reference/forms/types/repeated.html#options

$builder
    ->add('password', RepeatedType::class, [
        'type' => PasswordType::class,
        'options' => ['always_empty' => false],
        'first_options'  => ['label' => 'Password'],
        'second_options' => ['label' => 'Repeat Password'],
    ])
;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM