如何将属性添加到嵌套字段PasswordType
(属性always_empty
)中?该代码不起作用:
$builder
->add('password', RepeatedType::class, [
'type' => PasswordType::class, [
'always_empty' => false
],
'first_options' => ['label' => 'Password'],
'second_options' => ['label' => 'Repeat Password'],
])
;
答案 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'],
])
;