IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

Problème lors de la validation d'un formulaire


Sujet :

Symfony PHP

  1. #1
    Membre habitué Avatar de magicbisous-nours
    Inscrit en
    Octobre 2005
    Messages
    277
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 277
    Points : 177
    Points
    177
    Par défaut Problème lors de la validation d'un formulaire
    Bonjour,
    J'ai surchargé le formulaire du FOSUserBundle pour lui ajouter certains champs.
    Voici sa définition (je mets aussi les formulaires imbriqués pour la compréhension) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <?php
    namespace projet\UserBundle\Form\Type;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilder;
    use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
     
    class UserType extends BaseType {
        public function buildForm(FormBuilder $builder, array $options)
      {
        parent::buildForm($builder, $options);
        $builder
          ->add('username', null, array('attr' => array('class' => 'inputText')))
          ->add('email', null, array('attr' => array('class' => 'inputText')))
          ->add('user_nom', null, array('attr' => array('class' => 'inputText')))
          ->add('user_prenom', null, array('attr' => array('class' => 'inputText')))
          ->add('user_tel_travail', null, array('attr' => array('class' => 'inputText')))
          ->add('user_fo', new UserFoType)
        ;
      }
     
      public function getDefaultOptions(array $options) {
            return array(
                'data_class' => 'projet\UserBundle\Entity\User',
            );
        }
     
      public function getName()
        {
            return 'projet_user_registration';
        }
     
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <?php
    namespace projet\UserBundle\Form\Type;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilder;
     
    class UserFoType extends AbstractType
    {
        public function buildForm(FormBuilder $builder, array $options) {
            $builder->add('ufo_date_naissance', 'birthday', array('widget' => 'single_text',
                                                              'input'      => 'datetime',
                                                              'format'     => 'dd/MM/yyyy',
                                                              'read_only'  => true,
                                                              'attr'       => array('class' => 'inputText')))
                    ->add('ufo_ref_locataire', null, array('attr' => array('class' => 'inputText')))
                    ->add('ufo_tel_portable', null, array('attr' => array('class' => 'inputText')))
                    ->add('ufo_tel_domicil', null, array('attr' => array('class' => 'inputText')))
                    ->add('ufo_tpc_id', 'entity', array('class' => 'projet\FrontOfficeBundle\Entity\Type_contact_privilegie'))
                    ->add('ufo_log_id', new LogementType)
            ;
        }
     
        public function getDefaultOptions(array $options) {
            return array(
                'data_class' => 'projet\UserBundle\Entity\User_fo',
            );
        }
     
        public function getName()
        {
            return 'UserFo';
        }
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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 projet\UserBundle\Form\Type;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilder;
    use projet\BackOfficeBundle\Form\Type\BailType;
     
     
    class LogementType extends AbstractType
    {
        public function buildForm(FormBuilder $builder, array $options)
        {
            $builder
                    ->add('log_bailleur', 'entity', array('class' => 'projet\BackOfficeBundle\Entity\Bailleur'))
                    ->add('log_adresse', null, array('attr' => array('class' => 'inputText')))
                    ->add('log_code_postal', null, array('read_only' => true, 'attr' => array('class' => 'inputText')))
                    ->add('log_commune', null, array('empty_value' => 'Choisir une commune', 'empty_data' => '-1'))
                    ->add('log_etage', null, array('attr' => array('class' => 'inputText')))
                    ->add('log_numero', null, array('attr' => array('class' => 'inputText')))
                    ->add('log_description', 'textarea')
                    ;
        }
     
        public function getDefaultOptions(array $options)
        {
            return array(
                'data_class' => 'projet\BackOfficeBundle\Entity\Logement',
            );
        }
     
        public function getName()
        {
            return 'projet_userBundle_logementType';
        }
    }
    Voici le message d'erreur que j'obtiens lors de la soumission du formulaire :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Catchable Fatal Error: Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be of the type array, object given
    J'ai identifié l'entity à l'origine de l'erreur. Voici son code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    <?php
     
    namespace projet\BackOfficeBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
    use projet\BackOfficeBundle\Entity\Type_chauffage;
    use projet\BackOfficeBundle\Entity\Mode_chauffage;
     
    /**
     * projet\BackOfficeBundle\Entity\Logement
     *
     * @ORM\Table(name="logement")
     * @ORM\Entity(repositoryClass="projet\BackOfficeBundle\Repository\LogementRepository")
     */
    class Logement
    {
        /**
         * @var integer $log_id
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         * @ORM\Column(name="log_id", type="integer")
         */
        private $log_id;
     
        /**
         * @var integer $log_ufo_id
         *
         * @ORM\Column(name="log_ufo_id", type="integer", nullable=false, unique=true)
         */
     
        private $log_reference;
     
        /**
         * @var string $log_adresse
         *
         * @ORM\Column(name="log_adresse", type="string", length=45, nullable=false)
         */
        private $log_adresse;
     
        /**
         * @var integer $log_code_postal
         *
         * @ORM\Column(name="log_code_postal", type="integer", nullable=false)
         */
        private $log_code_postal;
     
        /**
         * @var integer $log_commune
         *
         * @ORM\ManyToOne(targetEntity="projet\BackOfficeBundle\Entity\Commune")
         * @ORM\JoinColumn(name="log_commune", referencedColumnName="com_id")
         */
        private $log_commune;
     
        /**
         * @var integer $log_etage
         *
         * @ORM\Column(name="log_etage", type="integer", nullable=true)
         */
        private $log_etage;
     
        /**
         * @var integer $log_numero
         *
         * @ORM\Column(name="log_numero", type="integer", nullable=true)
         */
        private $log_numero;
     
        /**
         * @var string $log_type_logement
         *
         * @ORM\Column(name="log_type_logement", type="string", length=255, nullable=true)
         */
        private $log_type_logement;
     
        /**
         * @var integer $log_typologie
         *
         * @ORM\ManyToOne(targetEntity="projet\BackOfficeBundle\Entity\Typologie")
         * @ORM\JoinColumn(name="log_typologie", referencedColumnName="tpg_id")
         */
        private $log_typologie;
     
        /**
         * @var string $log_latitude
         *
         * @ORM\Column(name="log_latitude", type="string", length=45, nullable=true)
         */
        private $log_latitude;
     
        /**
         * @var string $log_longitude
         *
         * @ORM\Column(name="log_longitude", type="string", length=45, nullable=true)
         */
        private $log_longitude;
     
        /**
         * @var string $log_nb_chambre
         *
         * @ORM\Column(name="log_nb_chambre", type="string", length=45, nullable=true)
         */
        private $log_nb_chambre;
     
        /**
         * @var string $log_surface
         *
         * @ORM\Column(name="log_surface", type="string", length=45, nullable=false)
         */
        private $log_surface;
     
        /**
         * @var boolean $log_ascenseur
         *
         * @ORM\Column(name="log_ascenseur", type="boolean")
         */
        private $log_ascenseur;
     
        /**
         * @var boolean $log_acc_pmr
         *
         * @ORM\Column(name="log_acc_pmr", type="boolean")
         */
        private $log_acc_pmr;
     
        /**
         * @var boolean $log_adaptation_pmr
         *
         * @ORM\Column(name="log_adaptation_pmr", type="boolean")
         */
        private $log_adaptation_pmr;
     
        /**
         * @var smallint $log_statut
         *
         * @ORM\Column(name="log_statut", type="smallint")
         */
        private $log_statut;
     
        /**
         * @var string $log_dpe
         *
         * @ORM\Column(name="log_dpe", type="string", length=10, nullable=false)
         */
        private $log_dpe;
     
        /**
         * @var string $log_description
         *
         * @ORM\Column(name="log_descriptif", type="string", length=500, nullable=true)
         */
        private $log_description;
     
        /**
         * @var datetime $log_annee_livraison
         *
         * @ORM\Column(name="log_annee_livraison", type="datetime", nullable=false)
         */
        private $log_annee_livraison;
     
            /**
         * @ORM\ManyToMany(targetEntity="projet\BackOfficeBundle\Entity\Type_chauffage", mappedBy="tch_id")
         * @ORM\JoinColumn(name="log_tch_id", referencedColumnName="tch_id")
         */
        private $log_tch_objects;
     
        /**
         * @ORM\ManyToMany(targetEntity="projet\BackOfficeBundle\Entity\Mode_chauffage", mappedBy="mch_id")
         * @ORM\JoinColumn(name="log_mch_id", referencedColumnName="mch_id")
         */
        private $log_mch_objects;
     
        /**
         * @ORM\ManyToOne(targetEntity="projet\BackOfficeBundle\Entity\Bailleur")
         * @ORM\JoinColumn(name="log_bailleur", referencedColumnName="blr_id")
         */
        private $log_bailleur;
     
        /**
         * @    ORM\Column(name="log_ufo_id", type="integer", nullable=false)
         * /
        private $log_ufo_id;
        
        /**
         * @var float $log_montant_loyer
         *
         * @ORM\Column(name="log_montant_loyer", type="float", nullable=false)
         */
        private $log_montant_loyer;
     
        /**
         * @var float $log_montant_charge
         *
         * @ORM\Column(name="log_montant_charge", type="float", nullable=false)
         */
        private $log_montant_charge;
     
        /**
         * @var string $log_charge_description
         *
         * @ORM\Column(name="log_charge_description", type="string", length=255, nullable=true)
         */
        private $log_charge_description;
     
        /**
         * @var datetime $log_date_entree
         *
         * @ORM\Column(name="log_date_entree", type="datetime", nullable=true)
         */
        private $log_date_entree;
     
        /**
         * @var datetime $log_date_sortie
         *
         * @ORM\Column(name="log_date_sortie", type="datetime", nullable=true)
         */
        private $log_date_sortie;
     
     
        public function __construct() {
            $this->log_tch_objects = new \Doctrine\Common\Collections\ArrayCollection();
            $this->log_mch_objects = new \Doctrine\Common\Collections\ArrayCollection();
        }
     
        /**
         * Set log_id
         *
         * @param integer $logId
         */
        public function setLogId($logId)
        {
            $this->log_id = $logId;
        }
     
        /**
         * Get log_id
         *
         * @return integer 
         */
        public function getLogId()
        {
            return $this->log_id;
        }
     
        /**
         * Set log_reference
         *
         * @param string $logReference
         */
        public function setLogReference($logReference)
        {
            $this->log_reference = $logReference;
        }
     
        /**
         * Get log_reference
         *
         * @return string 
         */
        public function getLogReference()
        {
            return $this->log_reference;
        }
     
        /**
         * Set log_adresse
         *
         * @param string $logAdresse
         */
        public function setLogAdresse($logAdresse)
        {
            $this->log_adresse = $logAdresse;
        }
     
        /**
         * Get log_adresse
         *
         * @return string 
         */
        public function getLogAdresse()
        {
            return $this->log_adresse;
        }
     
        /**
         * Set log_code_postal
         *
         * @param integer $logCodePostal
         */
        public function setLogCodePostal($logCodePostal)
        {
            $this->log_code_postal = $logCodePostal;
        }
     
        /**
         * Get log_code_postal
         *
         * @return integer 
         */
        public function getLogCodePostal()
        {
            return $this->log_code_postal;
        }
     
        /**
         * Set log_commune
         *
         * @param integer $logCommune
         */
        public function setLogCommune($logCommune)
        {
            $this->log_commune = $logCommune;
        }
     
        /**
         * Get log_commune
         *
         * @return integer 
         */
        public function getLogCommune()
        {
            return $this->log_commune;
        }
     
        /**
         * Set log_etage
         *
         * @param integer $logEtage
         */
        public function setLogEtage($logEtage)
        {
            $this->log_etage = $logEtage;
        }
     
        /**
         * Get log_etage
         *
         * @return integer 
         */
        public function getLogEtage()
        {
            return $this->log_etage;
        }
     
        /**
         * Set log_numero
         *
         * @param integer $logNumero
         */
        public function setLogNumero($logNumero)
        {
            $this->log_numero = $logNumero;
        }
     
        /**
         * Get log_numero
         *
         * @return integer 
         */
        public function getLogNumero()
        {
            return $this->log_numero;
        }
     
        /**
         * Set log_type_logement
         *
         * @param string $logTypeLogement
         */
        public function setLogTypeLogement($logTypeLogement)
        {
            $this->log_type_logement = $logTypeLogement;
        }
     
        /**
         * Get log_type_logement
         *
         * @return string 
         */
        public function getLogTypeLogement()
        {
            return $this->log_type_logement;
        }
     
        /**
         * Set log_typologie
         *
         * @param integer $logTypologie
         */
        public function setLogTypologie($logTypologie)
        {
            $this->log_typologie = $logTypologie;
        }
     
        /**
         * Get log_typologie
         *
         * @return integer 
         */
        public function getLogTypologie()
        {
            return $this->log_typologie;
        }
     
        /**
         * Set log_latitude
         *
         * @param string $logLatitude
         */
        public function setLogLatitude($logLatitude)
        {
            $this->log_latitude = $logLatitude;
        }
     
        /**
         * Get log_latitude
         *
         * @return string 
         */
        public function getLogLatitude()
        {
            return $this->log_latitude;
        }
     
        /**
         * Set log_longitude
         *
         * @param string $logLongitude
         */
        public function setLogLongitude($logLongitude)
        {
            $this->log_longitude = $logLongitude;
        }
     
        /**
         * Get log_longitude
         *
         * @return string 
         */
        public function getLogLongitude()
        {
            return $this->log_longitude;
        }
     
        /**
         * Set log_nb_chambre
         *
         * @param string $logNbChambre
         */
        public function setLogNbChambre($logNbChambre)
        {
            $this->log_nb_chambre = $logNbChambre;
        }
     
        /**
         * Get log_nb_chambre
         *
         * @return string 
         */
        public function getLogNbChambre()
        {
            return $this->log_nb_chambre;
        }
     
        /**
         * Set log_surface
         *
         * @param string $logSurface
         */
        public function setLogSurface($logSurface)
        {
            $this->log_surface = $logSurface;
        }
     
        /**
         * Get log_surface
         *
         * @return string 
         */
        public function getLogSurface()
        {
            return $this->log_surface;
        }
     
        /**
         * Set log_ascenseur
         *
         * @param boolean $logAscenseur
         */
        public function setLogAscenseur($logAscenseur)
        {
            $this->log_ascenseur = $logAscenseur;
        }
     
        /**
         * Get log_ascenseur
         *
         * @return boolean 
         */
        public function getLogAscenseur()
        {
            return $this->log_ascenseur;
        }
     
        /**
         * Set log_acc_pmr
         *
         * @param boolean $logAccPmr
         */
        public function setLogAccPmr($logAccPmr)
        {
            $this->log_acc_pmr = $logAccPmr;
        }
     
        /**
         * Get log_acc_pmr
         *
         * @return boolean 
         */
        public function getLogAccPmr()
        {
            return $this->log_acc_pmr;
        }
     
        /**
         * Set log_adaptation_pmr
         *
         * @param boolean $logAdaptationPmr
         */
        public function setLogAdaptationPmr($logAdaptationPmr)
        {
            $this->log_adaptation_pmr = $logAdaptationPmr;
        }
     
        /**
         * Get log_adaptation_pmr
         *
         * @return boolean 
         */
        public function getLogAdaptationPmr()
        {
            return $this->log_adaptation_pmr;
        }
     
        /**
         * Set log_statut
         *
         * @param smallint $logStatut
         */
        public function setLogStatut($logStatut)
        {
            $this->log_statut = $logStatut;
        }
     
        /**
         * Get log_statut
         *
         * @return smallint 
         */
        public function getLogStatut()
        {
            return $this->log_statut;
        }
     
        /**
         * Set log_dpe
         *
         * @param string $logDpe
         */
        public function setLogDpe($logDpe)
        {
            $this->log_dpe = $logDpe;
        }
     
        /**
         * Get log_dpe
         *
         * @return string 
         */
        public function getLogDpe()
        {
            return $this->log_dpe;
        }
     
        /**
         * Set log_description
         *
         * @param string $logDescription
         */
        public function setLogDescription($logDescription)
        {
            $this->log_description = $logDescription;
        }
     
        /**
         * Get logDescription,
         *
         * @return string 
         */
        public function getLogDescription()
        {
            return $this->log_description;
        }
     
        /**
         * Set log_annee_livraison
         *
         * @param datetime $logAnneeLivraison
         */
        public function setLogAnneeLivraison($logAnneeLivraison)
        {
            $this->log_annee_livraison = $logAnneeLivraison;
        }
     
        /**
         * Get log_annee_livraison
         *
         * @return datetime 
         */
        public function getLogAnneeLivraison()
        {
            return $this->log_annee_livraison;
        }
     
        /**
         * Set $log_mch_objects
         *
         * @param array $logMchId
         */
        public function addLogMchObjects(Mode_chauffage $logMchId)
        {
            $this->log_mch_objects[] = $logMchId;
        }
     
        /**
         * Get log_mch_objects
         *
         * @return \Doctrine\Common\Collections\Collection 
         */
        public function getLogMchObjects()
        {
            return $this->log_mch_objects;
        }
     
        /**
         * Set log_mch_objects
         *
         * @param \Doctrine\Common\Collections\Collection 
         */
        public function setLogMchObjects(\Doctrine\Common\Collections\Collection $LogMchObjects)
        {
            $this->log_mch_objects = $LogMchObjects;
        }
     
        /**
         * Set $log_tch_objects
         *
         * @param array $logTchId
         */
        public function addLogTchObjects(Type_chauffage $logTchId)
        {
            $this->log_tch_objects[] = $logTchId;
        }
     
        /**
         * Get log_tch_objects
         *
         * @return \Doctrine\Common\Collections\Collection 
         */
        public function getLogTchObjects()
        {
            return $this->log_tch_objects;
        }
     
        /**
         * Set log_tch_objects
         *
         * @param \Doctrine\Common\Collections\Collection 
         */
        public function setLogTchObjects(\Doctrine\Common\Collections\Collection $LogTchObjects)
        {
            $this->log_tch_objects = $LogTchObjects;
        }
     
        /**
         * Set log_montant_loyer
         *
         * @param float $logMontantLoyer
         */
        public function setLogMontantLoyer($logMontantLoyer)
        {
            $this->log_montant_loyer = $logMontantLoyer;
        }
     
        /**
         * Get log_montant_loyer
         *
         * @return float 
         */
        public function getLogMontantLoyer()
        {
            return $this->log_montant_loyer;
        }
     
        /**
         * Set log_montant_charge
         *
         * @param float $logMontantCharge
         */
        public function setLogMontantCharge($logMontantCharge)
        {
            $this->log_montant_charge = $logMontantCharge;
        }
     
        /**
         * Get log_montant_charge
         *
         * @return float 
         */
        public function getLogMontantCharge()
        {
            return $this->log_montant_charge;
        }
     
        /**
         * Set log_charge_description
         *
         * @param string $logChargeDescription
         */
        public function setLogChargeDescription($logChargeDescription)
        {
            $this->log_charge_description = $logChargeDescription;
        }
     
        /**
         * Get log_charge_description
         *
         * @return string 
         */
        public function getLogChargeDescription()
        {
            return $this->log_charge_description;
        }
     
        /**
         * Set log_date_entree
         *
         * @param datetime $logDateEntree
         */
        public function setLogDateEntree($logDateEntree)
        {
            $this->log_date_entree = $logDateEntree;
        }
     
        /**
         * Get log_date_entree
         *
         * @return datetime 
         */
        public function getLogDateEntree()
        {
            return $this->log_date_entree;
        }
     
        /**
         * Set log_date_sortie
         *
         * @param datetime $logDateSortie
         */
        public function setLogDateSortie($logDateSortie)
        {
            $this->log_date_sortie = $logDateSortie;
        }
     
        /**
         * Get log_date_sortie
         *
         * @return datetime 
         */
        public function getLogDateSortie()
        {
            return $this->log_date_sortie;
        }
     
        /**
         * Add log_tch_objects
         *
         * @param projet\BackOfficeBundle\Entity\Type_chauffage $logTchObjects
         */
        public function addType_chauffage(\projet\BackOfficeBundle\Entity\Type_chauffage $logTchObjects)
        {
            $this->log_tch_objects[] = $logTchObjects;
        }
     
        /**
         * Add log_mch_objects
         *
         * @param projet\BackOfficeBundle\Entity\Mode_chauffage $logMchObjects
         */
        public function addMode_chauffage(\projet\BackOfficeBundle\Entity\Mode_chauffage $logMchObjects)
        {
            $this->log_mch_objects[] = $logMchObjects;
        }
     
        /**
         * Set log_bailleur
         *
         * @param projet\BackOfficeBundle\Entity\Bailleur $log_bailleur
         */
        public function setLogBailleur(\projet\BackOfficeBundle\Entity\Bailleur $log_bailleur)
        {
            $this->log_bailleur = $log_bailleur;
        }
     
        /**
         * Get log_bailleur
         *
         * @return BEL\BackOfficeBundle\Entity\Bailleur 
         */
        public function getLogBailleur()
        {
            return $this->log_bailleur;
        }
    }
    Quelqu'un saurait d'où provient mon problème ?

    Merci d'avance
    [/HS]

    J'adorerai changer le monde, mais pas moyen de mettre la main sur le code source

  2. #2
    Membre expert Avatar de Fench
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Mai 2002
    Messages
    2 353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Groenland

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 353
    Points : 3 390
    Points
    3 390
    Par défaut
    Bonjour,

    D'après l'erreur, tu lui envoies un objet à la place d'un tableau ...
    Ca ne viendrait pas de là:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ->add('log_bailleur', 'entity', array('class' => 'projet\BackOfficeBundle\Entity\Bailleur'))
    Meuuh en AI à l'INRA
    Domaines: {java, php, js, jquery}{hibernate, doctrine}{MyLib, symfony, Zend}
    fait gagner du temps à ceux qui aident , donc un message avec la balise résolu laisse plus de temps pour résoudre d'autres problèmes (balise à cliquer en bas de l'écran)

  3. #3
    Membre habitué Avatar de magicbisous-nours
    Inscrit en
    Octobre 2005
    Messages
    277
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 277
    Points : 177
    Points
    177
    Par défaut
    euh... peut être bien....
    J'ai pourtant bien fait un ManyToOne comme jointure dans Logement (pour dire qu'un Logement n'a qu'un Bailleur mais qu'un Bailleur peut avoir plusieurs Logements)
    Y-aurait-il une erreur dans ma logique ?

    [EDIT] Non ça ne vient pas de là : j'ai viré ce champ du formulaire pour tester et j'ai la même erreur....

    Merci d'avance
    [/HS]

    J'adorerai changer le monde, mais pas moyen de mettre la main sur le code source

  4. #4
    Membre habitué Avatar de magicbisous-nours
    Inscrit en
    Octobre 2005
    Messages
    277
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 277
    Points : 177
    Points
    177
    Par défaut
    J'ai trouvé !
    En fait tu m'as mis sur la voie Fench.
    Dans mon entité User_fo j'avais une relation OneToMany vers Logement et je lui passais un objet de type Logement au lieu d'une ArrayCollection !!

    Maintenant j'ai corrigé ça et je me heurte à un autre problème... Voici le code de mon entité User_fo :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    <?php
    namespace projet\UserBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
    use Symfony\Component\Validator\Constraints as Assert;
     
    /**
     * projet\UserBundle\Entity\User_fo
     *
     * @ORM\Table(name="fos_user_fo")
     * @ORM\Entity(repositoryClass="projet\UserBundle\Repository\User_foRepository")
     */
    class User_fo
    {
        /**
         * @var integer $ufo_id
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         * @ORM\Column(name="ufo_id", type="integer")
         */
        private $ufo_id;
     
        /**
         * @var integer $ufo_user_id
         * @ORM\Column(name="ufo_user_id", type="integer", nullable=false)
         */
        private $ufo_user_id;
     
        /**
         * @var integer $ufo_ins_id
         *
         * @ORM\OneToOne(targetEntity="projet\BackOfficeBundle\Entity\Inscription")
         * @ORM\JoinColumn(name="ufo_ins_id", referencedColumnName="ins_id")
         */
        private $ufo_ins_id;
     
        /**
         * @var datetime $ufo_date_naissance
         *
         * @ORM\Column(name="ufo_date_naissance", type="datetime", nullable=false)
         * @Assert\Date()
         */
        private $ufo_date_naissance;
     
        /**
         * @var string $ufo_ref_locataire
         *
         * @ORM\Column(name="ufo_ref_locataire", type="string", length=45, nullable=false, unique=true)
         */
        private $ufo_ref_locataire;
     
        /**
         * @var string $ufo_tel_portable
         *
         * @ORM\Column(name="ufo_tel_portable", type="string", length=45, nullable=false)
         */
        private $ufo_tel_portable;
     
        /**
         * @var string $ufo_tel_domicil
         *
         * @ORM\Column(name="ufo_tel_domicil", type="string", length=45, nullable=true)
         */
        private $ufo_tel_domicil;
     
        /**
         * @var integer $ufo_tpc_id
         *
         * @ORM\ManyToOne(targetEntity="projet\FrontOfficeBundle\Entity\Type_contact_privilegie")
         * @ORM\JoinColumn(name="ufo_tcp_id", referencedColumnName="tcp_id")
         */
        private $ufo_tcp_id;
     
        /**
         * @var integer $ufo_statut
         *
         * @ORM\Column(name="ufo_statut", type="integer", nullable=false)
         */  
        private $ufo_statut;
     
        /**
         * @var \Doctrine\Common\Collections\ArrayCollection 
         * 
         * @ORM\OneToMany(targetEntity="projet\BackOfficeBundle\Entity\Logement", mappedBy="log_ufo_id",cascade={"persist", "remove"})
         */
        private $ufo_log_id;
     
        public function __construct() {
            $this->ufo_log_id = new \Doctrine\Common\Collections\ArrayCollection();
        }
     
        /**
         * Set ufo_id
         *
         * @param integer $ufoId
         */
        public function setUfoId($ufoId)
        {
            $this->ufo_id = $ufoId;
        }
     
        /**
         * Get ufo_id
         *
         * @return integer 
         */
        public function getUfoId()
        {
            return $this->ufo_id;
        }
     
        /**
         * Set ufo_date_naissance
         *
         * @param datetime $ufoDateNaissance
         */
        public function setUfoDateNaissance(DateTime $ufoDateNaissance)
        {
            $this->ufo_date_naissance = $ufoDateNaissance;
        }
     
        /**
         * Get ufo_date_naissance
         *
         * @return datetime 
         */
        public function getUfoDateNaissance()
        {
            return $this->ufo_date_naissance;
        }
     
        /**
         * Set ufo_ref_locataire
         *
         * @param string $ufoRefLocataire
         */
        public function setUfoRefLocataire($ufoRefLocataire)
        {
            $this->ufo_ref_locataire = $ufoRefLocataire;
        }
     
        /**
         * Get ufo_ref_locataire
         *
         * @return string 
         */
        public function getUfoRefLocataire()
        {
            return $this->ufo_ref_locataire;
        }
     
        /**
         * Set ufo_tel_portable
         *
         * @param string $ufoTelPortable
         */
        public function setUfoTelPortable($ufoTelPortable)
        {
            $this->ufo_tel_portable = $ufoTelPortable;
        }
     
        /**
         * Get ufo_tel_portable
         *
         * @return string 
         */
        public function getUfoTelPortable()
        {
            return $this->ufo_tel_portable;
        }
     
        /**
         * Set ufo_tel_domicil
         *
         * @param string $ufoTelDomicil
         */
        public function setUfoTelDomicil($ufoTelDomicil)
        {
            $this->ufo_tel_domicil = $ufoTelDomicil;
        }
     
        /**
         * Get ufo_tel_domicil
         *
         * @return string 
         */
        public function getUfoTelDomicil()
        {
            return $this->ufo_tel_domicil;
        }
     
        /**
         * Set ufo_tcp_id
         *
         * @param integer $ufoTcpId
         */
        public function setUfoTcpId($ufoTcpId)
        {
            $this->ufo_tcp_id = $ufoTcpId;
        }
     
        /**
         * Get ufo_tcp_id
         *
         * @return integer 
         */
        public function getUfoTcpId()
        {
            return $this->ufo_tcp_id;
        }
     
        /**
         * Set ufo_statut
         *
         * @param integer $ufoStatut
         */
        public function setUfoStatut($ufoStatut)
        {
            $this->ufo_statut = $ufoStatut;
        }
     
        /**
         * Get ufo_statut
         *
         * @return integer 
         */
        public function getUfoStatut()
        {
            return $this->ufo_statut;
        }
     
        /**
         * Set ufo_user_id
         *
         * @param integer $ufoUserId
         */
        public function setUfoUserId($ufoUserId)
        {
            $this->ufo_user_id = $ufoUserId;
        }
     
        /**
         * Get ufo_user_id
         *
         * @return integer 
         */
        public function getUfoUserId()
        {
            return $this->ufo_user_id;
        }
     
        /**
         * Set ufo_ins_id
         *
         * @param integer $ufoInsId
         */
        public function setUfoInsId($ufoInsId)
        {
            $this->ufo_ins_id = $ufoInsId;
        }
     
        /**
         * Get ufo_ins_id
         *
         * @return integer 
         */
        public function getUfoInsId()
        {
            return $this->ufo_ins_id;
        }
     
        /**
         * Set ufo_log_id
         *
         * @param projet\BackOfficeBundle\Entity\Logement $ufoLogId
         */
        public function setUfoLogId(\Doctrine\Common\Collections\ArrayCollection $ufoLogId)
        {
            $this->ufo_log_id = $ufoLogId;
        }
     
        /**
         * Get ufo_log_id
         *
         * @return projet\BackOfficeBundle\Entity\Logement
         */
        public function getUfoLogId()
        {
            return $this->ufo_log_id;
        }
    }
    Le nouveau code de mon formulaire UserFoType :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    36
    <?php
    namespace projet\UserBundle\Form\Type;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilder;
     
    class UserFoType extends AbstractType
    {
        public function buildForm(FormBuilder $builder, array $options) {
            $builder->add('ufo_date_naissance', 'birthday', array('widget' => 'single_text',
                                                              'input'      => 'datetime',
                                                              'format'     => 'dd/MM/yyyy',
                                                              'read_only'  => true,
                                                              'attr'       => array('class' => 'inputText')))
                    ->add('ufo_ref_locataire', null, array('attr' => array('class' => 'inputText')))
                    ->add('ufo_tel_portable', null, array('attr' => array('class' => 'inputText')))
                    ->add('ufo_tel_domicil', null, array('attr' => array('class' => 'inputText')))
                    ->add('ufo_tcp_id', 'entity', array('class' => 'projet\FrontOfficeBundle\Entity\Type_contact_privilegie'))
                    ->add('ufo_log_id', 'collection', array('type'         => new LogementType(),
                                                            'allow_add'    => true,
                                                            'prototype'    => true,
                                                            'attr' => array('class' => 'form_added')))
            ;
        }
     
        public function getDefaultOptions(array $options) {
            return array(
                'data_class' => 'projet\UserBundle\Entity\User_fo',
            );
        }
     
        public function getName()
        {
            return 'UserFo';
        }
    }
    Et voici mon erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Catchable Fatal Error: Argument 1 passed to BEL\UserBundle\Entity\User_fo::setUfoLogId() must be an instance of Doctrine\Common\Collections\ArrayCollection, array given
    Comment cela se fait-il qu'il passe un array et non une ArrayCollection ?

    Merci d'avance
    [/HS]

    J'adorerai changer le monde, mais pas moyen de mettre la main sur le code source

Discussions similaires

  1. Réponses: 6
    Dernier message: 24/04/2013, 17h14
  2. [2.x] [Validation] Problème lors de la validation d'un formulaire
    Par loon93 dans le forum Symfony
    Réponses: 3
    Dernier message: 22/08/2011, 20h34
  3. problème de doublon lors de la validation d'un formulaire
    Par barouz dans le forum Servlets/JSP
    Réponses: 4
    Dernier message: 01/06/2007, 10h45
  4. Ouvrir une popup lors de la validation d'un formulaire
    Par pod1978 dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 23/11/2005, 15h47
  5. Réponses: 2
    Dernier message: 21/11/2005, 09h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo