是否可能在ez publish 5中的同一页面上有3个或更多表单?
当我把这样的3个表格
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
只渲染第一种形式而不是其他形式。
和第二个问题,我想在ez发布中使用一个类用于多个表单,是否可能?
任何链接或建议对我有帮助
答案 0 :(得分:0)
您可以在表单中使用表单。
示例表1:
class MyRegistrationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('firstname', TextType::class, array(
'label_attr' => ['style' => 'display:none'],
'attr' => ['placeholder' => 'form.profile.firstname']
));
}
}
示例表2:
class RegistrationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
// Add Self Form
$builder
->add('email', EmailType::class, array(
'attr' => ['placeholder' => 'form.email'],
'label_attr' => ['style' => 'display:none'],
'translation_domain' => 'FOSUserBundle',
));
// Include First Form
$builder->add('Profile', MyRegistrationType::class, array(
'mapped' => true,
'label' => false,
'required' => true
));
}
}
在控制器中使用表单:
// Create Form
$form = $this->createForm(RegistrationType::class);
渲染树枝:
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}