Reputation: 51
is it possible have 3 or more forms on the same page with same class in ez publish 5 ?
when i put 3 form like this
{{ 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) }}
render only first form not others.
and the second question , i want use one class for multiple forms in ez publish, is it possible ?
any link or suggest would be helpful for me
Upvotes: 0
Views: 74
Reputation: 836
You can use form in form.
Example Form 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']
));
}
}
Example Form 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
));
}
}
Using Form in Controller:
// Create Form
$form = $this->createForm(RegistrationType::class);
Render Twig:
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
Upvotes: 0