Bonjour,
Je suis en train de faire un formulaire imbriqué mais j'ai l'erreur suivante
Expected argument of type "Demo\ArbreBundle\Entity\Note", "Doctrine\Common\Collections\ArrayCollection" given
Pour la mise en situation, un utilisateur note une idée
Donc dans le formulaire des idées j'ai ca
IdéeType
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| <?php
namespace Demo\ArbreBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class IdeeType extends AbstractType {
public function buildForm(FormBuilder $builder, array $options) {
$builder
->add('libelle')
->add('description', 'textarea', array('attr' => array('class' => 'demo_arbrebundle_ideetype_description')))
->add('etat', 'choice', array('choices' => array('1' => 'Actif', '0' => 'Inactif'), 'expanded' => true))
->add('theme')
->add('note', new NoteType)
;
}
public function getName() {
return 'demo_arbrebundle_ideetype';
}
} |
Et voici mon NoteType
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| <?php
namespace Demo\ArbreBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class NoteType extends AbstractType {
public function buildForm(FormBuilder $builder, array $options) {
$builder
->add('note', 'choice', array(
'choices' => array(
'3' => 3,
'7' => 7,
'14' => 14,
'30' => 30,
'60' => 60,
'90' => 90,
)
));
;
}
public function getName() {
return 'demo_arbrebundle_notetype';
}
public function getDefaultOptions(array $options) {
return array(
'data_class' => 'Demo\ArbreBundle\Entity\Note',
);
}
} |
Merci de vos réponses
Partager