【发布时间】:2013-04-24 14:32:41
【问题描述】:
如何防止表单 - 通过 Symfony2 - FosUserBundle 呈现 - 被嵌套? 构建器有两个字段,其中一个是重复字段。看来这将被渲染为嵌套
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('current_password', 'password', array(
'label' => 'form.current_password',
'translation_domain' => 'FOSUserBundle',
'mapped' => false,
'constraints' => new UserPassword(),
));
$builder->add('new', 'repeated', array(
'type' => 'password',
'options' => array('translation_domain' => 'FOSUserBundle'),
'first_options' => array('label' => 'form.new_password'),
'second_options' => array('label' => 'form.new_password_confirmation'),
'invalid_message' => 'fos_user.password.mismatch',
));
}
当表单被渲染时,我得到的是: http://pastebin.com/Np2bvgvH
如您所见,重复的表单字段被包裹在另一个“FormRows”-div 中。我希望它们是简单的“FormRow”-div,没有额外的 FormRows。布局并不意味着有两个嵌套的 FormRows
希望你能理解我的问题。
谢谢
【问题讨论】:
标签: php forms symfony nested fosuserbundle