I would like to create a form which can add multiple etape. I create the form like this:
页: 1
namespace RBOTryBundleFormType;
use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilder;
use RBOTryBundleEntityTry;
class TryType extends AbstractType {
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add( etapes , collection , array(
type => new EtapeType(),
allow_add => true,
allow_delete => true,
prototype => true,
label => Etapes
));
iii
public function getName()
{
return try ;
iii
public function getDefaultOptions(array $options)
{
return array(
data_class => RBOTryBundleEntityTry ,
csrf_protection => true,
csrf_field_name => _token ,
// a unique key to help generate the secret token
intention => try_item ,
);
iii
iii
// EtapeType
<?php
namespace RBOTryBundleFormType;
use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilder;
use RBOTryBundleEntityEtape;
class EtapeType extends AbstractType {
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add( name , text );
iii
public function getDefaultOptions(array $options)
{
return array(
data_class => RBOTryBundleEntityEtape ,
);
iii
public function getName()
{
return etape ;
iii
iii
// Display in twig template
{{ form_row(form.etapes) iiiiii
实体 提炼有一种财产排泄物,是一种阿雷拉角(由建筑商界定)
这部法典根本不希望贴上标签。 我是否误解了什么?
事先感谢你