Bonjour,

J'ai créé un formulaire pour un module "annonce" et je souhaite rajouter des photos pour chaque annonce.Sachant que j'ai un attribut dans la table annonce "PhotoPrincipale" ou je peux charger une photo sans aucun souci dans la classe annonceForm avec :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
 
$this->widgetSchema['photoPrincipale'] = new sfWidgetFormInputFile(array(
     'label' => 'Photo Principale',
));
 
$this->validatorSchema['photoPrincipale'] = new sfValidatorFile(array(
  'required'   => false,
  'path'       => sfConfig::get('sf_upload_dir').'/photos',
  'mime_types' => 'web_images',
));

Pour rajouter des photos supplémentaire j'ai du créer une table photo

annonce---0,n------Avoir-------1,1----photo

La question est comment intégrer le rajout de ces photos dans le même formulaire de l'annonce donc comment les rajouter dans la class AnnonceForm ?

J'ai pensé à rajouter :

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
 
$this->embedRelation('Photo');
 
$this->widgetSchema['photoPrincipale'] = new sfWidgetFormInputFile(array(
     'label' => 'Photo Principale',
));
 
$this->validatorSchema['photoPrincipale'] = new sfValidatorFile(array(
  'required'   => false,
  'path'       => sfConfig::get('sf_upload_dir').'/photos',
  'mime_types' => 'web_images',
));
 
 
$this->widgetSchema['Intitule'] = new sfWidgetFormInputFile(array(
     'label' => 'Photo n : 2',
));
 
$this->validatorSchema['Intitule'] = new sfValidatorFile(array(
  'required'   => false,
  'path'       => sfConfig::get('sf_upload_dir').'/photos',
  'mime_types' => 'web_images',
));
Sachant que intitulé est un attribut dans la table Photo.

Mais ça marche pas j'ai cette erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
Unknown record property / related component "Intitule" on "Annonce"
 
public function filterGet(Doctrine_Record $record, $name)
{
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $name,   get_class($record)));
}
 
}


Merci d'avance .