Problème avec les Embedded Forms
Bonjour, :cry:
Je m'excuse d'avance si mon problème serai débile :aie: mais j'arrive pas a trouvé une solution, sachant que j'ai essayé de suivre ce tutoriel a la lettre :
http://nibsirahsieu.wordpress.com/20...embedded-form/
Mon problème est le suivant, je travail sur l'administration d'un site de booking (réservation des chambres d'hotels).
là ou je bloque est lors de l'ajout d'une nouvelle chambre (modification aussi), pendant laquel je dois récupéré les "saisons" depuis l'hotel en question, et pouvoir creer des enregistrement des saisons + les tarifs dans une nouvelle tables en même temps que l'ajout de la chambre.
voici en ce qui suit mon schema de la base de donnée.
Code:
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
| Chambre:
connection: doctrine
tableName: chambre
columns:
id_chambre:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
id_etb:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
id_type:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
id_pension:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
nom_chambre:
type: string(30)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
desc_chambre_fr:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
desc_chambre_en:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
desc_chambre_es:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
desc_chambre_it:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
nombre:
type: integer(1)
fixed: false
unsigned: false
primary: false
default: '1'
notnull: false
autoincrement: false
ch_pax:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
lit_sup:
type: integer(1)
fixed: false
unsigned: false
primary: false
default: '0'
notnull: false
autoincrement: false
prix_lit_sup:
type: float()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
commision:
type: float()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
image:
type: string(120)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Etablissement:
local: id_etb
foreign: id_etb
type: one
Chtype:
local: id_type
foreign: id_type
type: one
Pension:
local: id_pension
foreign: id_pension
type: one
Chsaison:
local: id_chambre
foreign: id_chambre
type: many
Chservices:
local: id_chambre
foreign: id_chambre
type: many
Chsaison:
connection: doctrine
tableName: chsaison
columns:
id_saison:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
id_chambre:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
date_debut:
type: date(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
date_fin:
type: date(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
prix:
type: float()
fixed: false
unsigned: false
primary: false
default: '0'
notnull: false
autoincrement: false
relations:
Chambre:
local: id_chambre
foreign: id_chambre
type: one |
voici le code que j'ai ajouté dans la classe ChambreForm.class.php :
Code:
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
| <?php
/**
* Chambre form.
*
* @package Booking
* @subpackage form
* @author Badr HAKKARI - badr.hakkari@gmail.com
* @version SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class ChambreForm extends BaseChambreForm {
public function configure() {
$saisons = Doctrine_Core::getTable('Etbsaison')
->createQuery('s')
->select('s.date_debut, s.date_fin,s.prix')
->where('id_etb = ?', $this->getOption('id_etb'))
->execute();
if ($saisons->count() > 0) {
$chsForms = new sfForm();
$lesSaisons = $this->getObject()->getChsaison();
if ($lesSaisons->count() == 0) {
foreach ($saisons as $saison) {
$chs = new Chsaison();
$chs->setChambre($this->getObject());
$chs->setDateDebut($saison->getDateDebut());
$chs->setDateFin($saison->getDateFin());
$chs->setPrix($saison->getPrix());
$lesSaisons[] = $chs;
}
}
foreach ($lesSaisons as $key => $v) {
$chsForm = new ChsaisonForm($v);
$chsForms->embedForm('chsaison' . ($key + 1), $chsForm);
$chsForms->widgetSchema['chsaison' . ($key + 1)]->setLabel('Saison: ' . ($key + 1));
}
$this->embedForm('chsForms', $chsForms);
$this->widgetSchema['chsForms']->setLabel('Les Saisons:');
}
}
public function addSaisons($key) {
$saisons = new Chsaison();
$saisons->setChambre($this->getObject());
$this->embeddedForms['chsForms']->embedForm($key, new ChsaisonForm($saisons));
$this->embedForm('chsForms', $this->embeddedForms['chsForms']);
}
public function bind(array $taintedValues = null, array $taintedFiles = null) {
if (isset($taintedValues['chsForms'])) {
foreach ($taintedValues['chsForms'] as $key => $form) {
if (false === $this->embeddedForms['chsForms']->offsetExists($key)) {
$this->addSaisons($key);
}
}
}
parent::bind($taintedValues, $taintedFiles);
}
} |
et finalement voici l'erreur que j'ai :
Code:
1 2
| Notice: Undefined index: chsForms in C:\wamp\www\projet\lib\form\doctrine\ChambreForm.class.php on line 56
Fatal error: Call to a member function offsetExists() on a non-object in C:\wamp\www\projet\lib\form\doctrine\ChambreForm.class.php on line 56 |
Merci d'avance pour votre aide.