Adjunto como he desarrollado el codigo:
Tengo el archivo del formulario y al final tengo el collection llamado 'tribe' :
Código PHP:
<?php
namespace ABCIsystemBundleForm;
use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilderInterface;
use SymfonyComponentOptionsResolverOptionsResolverInterface;
use ABCIsystemBundleEntityAbcMembersGroups;
use ABCIsystemBundleFormAbcMembersGroupsType;
use ABCIsystemBundleEntityAbcMemberMediaCommunication;
use ABCIsystemBundleFormAbcMemberMediaCommunicationType;
class AbcMembersStudentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('idCard','text',array('label'=>'IDCARD','read_only'=>true))
->add('admonCode','text',array('label'=>'ADMON CODE','required'=>false))
->add('lastname','text',array('label'=>'Lastname *'))
->add('firstname','text',array('label'=>'Fistname *'))
->add('middlename','text',array('label'=>'Middlename','required'=>false))
->add('birthdate', 'date', array(
'widget' => 'single_text',
'format' => 'dd-MM-yyyy'))
->add('gender','choice',array(
'label'=>'Choose a gender *',
'empty_value' => 'Choose a gender',
'choices'=> array(
'female' => 'Female',
'male' => 'Male',
)))
->add('placeOfBirthdate')
->add('nickname')
->add('login','text',array('read_only'=>true))
->add('sitewideLogin')
->add('status','choice',array(
'label'=>'Choose an Status *',
'empty_value' => 'Choose an option',
'choices'=> array(
'active' => 'Active',
'no_active' => 'No Active',
)))
//->add('createdDate')
//->add('password')
//->add('salt')
->add('saludation','entity',
array(
'label'=>'Saludation *',
'class'=>'ABCIsystemBundle:AbcSadulation',
'property'=>'abbreviationEn',
))
->add('tribe', 'collection', array(
'type' => new AbcStudentsType(),
'label' => false,
'allow_add' => false,
'allow_delete' => false,
'by_reference' => true,
))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'ABC\IsystemBundle\Entity\AbcMembers'
));
}
public function getName()
{
return 'abc_isystembundle_abcmembersstudenttype';
}
}
Código PHP:
<?php
namespace ABCIsystemBundleForm;
use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilderInterface;
use SymfonyComponentOptionsResolverOptionsResolverInterface;
class AbcStudentsType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
/* ->add('classYear')
->add('createdDate')
->add('idCourseSubsesion')
->add('tribe')
->add('member') */
->add('tribe','entity',
array(
'class'=>'ABCIsystemBundle:AbcTribe',
'label'=>'Tribe *',
'property'=>'name',
))
->add('classYear','text',array('label'=>'Class year *'))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'ABC\IsystemBundle\Entity\AbcStudents'
));
}
public function getName()
{
return 'abc_isystembundle_abcstudentstype';
}
}
0
Tribe *
(Una lista desplegable)
Class year *
(Un text)
Entonces en twig no mando a imprimir ese "0" pero no se porque me lo esta imprimiendo.