您可以在窗體中使用窗體。
實施例形式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) }}
它是一樣的形式嗎? –
你的問題不是很清楚。你想從ez Classes創建表單並在前端創建對象而不是/ ez Backoffice?你的控制器是怎樣的? –