Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/10/2013, 11:48
carlosml08
 
Fecha de Ingreso: septiembre-2013
Mensajes: 61
Antigüedad: 10 años, 7 meses
Puntos: 0
Problema con el collection de symfony2

Buen dia amigos, tengo un formulario y dentro de el tengo un collection el cual me esta imprimiendo el numero 0 de mas cuando yo no lo estoy mandando a imprimir.
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';
    }
}
Tengo el formulario llamado AbcStudentsType.php
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';
    }
}
Ahorra cuando veo el formulario en el navegador me aparece lo siguiente:
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.