将属性添加到嵌套字段

时间:2018-07-10 23:39:49

标签: php symfony

如何将属性添加到嵌套字段PasswordType(属性always_empty)中?该代码不起作用:

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

1 个答案:

答案 0 :(得分:0)

它属于“选项”数组。

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'],
    ])
;