如何在视图中分离 RepeatedType 小部件?

How can I separate RepeatedType widget in the view?

我在 ResetPassword 系统上工作,这是用户在收到电子邮件后输入新密码的页面。

基本上我想做的就是把view page里的RepeatedType分开!

在视图(.twig)中我有:

{{ form_start(resetForm) }}
    {{ form_widget(resetForm.plainPassword) }}
    <button>Reset password</button> 
{{ form_end(resetForm) }}

而不是

{{ form_widget(resetForm.plainPassword) }}

我想将它们分开并制作类似的东西:

{{ form_widget(resetForm.plainPassword[1]) }}
{{ form_widget(resetForm.plainPassword[2]) }}

这可能吗?如果是,正确的语法是什么?

这里是 ChangePasswordFormType.php 的代码:

class ChangePasswordFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('plainPassword', RepeatedType::class, [
                'type' => PasswordType::class,
                'first_options' => [
                    'attr' => [
                         'class' => 'form-control form-control-sm',
                    ],
                    'constraints' => [
                        new NotBlank([
                            'message' => 'Please enter a password',
                        ]),
                        new Length([
                            'min' => 6,
                            'minMessage' => 'Your password should be at least {{ limit }} characters',
                            // max length allowed by Symfony for security reasons
                            'max' => 4096,
                        ]),
                    ],
                    'label' => 'New password :',
                ],
                'second_options' => [
                    'attr' => [
                         'class' => 'form-control',
                    ],
                    'label' => 'Repeat it :',
                ],
                'invalid_message' => 'The password fields must match.',
                // Instead of being set onto the object directly,
                // this is read and encoded in the controller
                'mapped' => false,
            ])
        ;
    }

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

{# .first and .second may vary in your use - see the note below #}
{{ form_row(form.password.first) }}
{{ form_row(form.password.second) }}