Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > symfony
symfony Forum d'entraide sur le framework PHP symfony. Avant de poster : cours symfony et FAQ symfony
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 18/12/2010, 16h40   #1
Invité régulier
 
Inscription : novembre 2010
Messages : 36
Détails du profil
Informations forums :
Inscription : novembre 2010
Messages : 36
Points : 8
Points : 8
Par défaut formulaire imbriqué ?

Bonjour,

J'ai le schéma suivant :


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
# config/doctrine/schema.yml
 
Annonce:
  actAs: { Timestampable: ~ }
  columns:
    Utilisateur_id: { type: integer, notnull: true }
    Categorie_id:   { type: integer, notnull: true }
    Region_id:      { type: integer, notnull: true }
    Departement_id: { type: integer, notnull: true }
    CodePostal:     { type: integer }
    Ville:          { type: string(255) }
    TexteAnnonce:   { type: string(4000) }
    TitreAnnonce:   { type: string(255) }
    Prix:           { type: integer}
    TypeAnnonce:    { type: string(255)}
    isAccomplished: { type: boolean, notnull: true, default: 0  }
    is_activated:   { type: boolean, notnull: true, default: 0 }
    expires_at:     { type: timestamp, notnull: true }
  relations:
    Utilisateur:    { onDelete: CASCADE, local: Utilisateur_id, foreign: id, foreignAlias: Utilisateur }
    Categorie:      { onDelete: CASCADE, local: Categorie_id, foreign: id }
    Region:         { onDelete: CASCADE, local: Region_id, foreign: id }
    Departement:    { onDelete: CASCADE, local: Departement_id, foreign: id }
Region:
  actAs:
    Sluggable:
      unique: true
      fields: [nom]
  columns:
    nom:      { type: string(255), notnull: true, unique: true }
Departement:
  columns:
    Region_id: { type: integer, notnull: true }
    nom:       { type: string(255), notnull: true }
  relations:
    Region:    { onDelete: CASCADE, local: Region_id, foreign: id }
Categorie:
  actAs: { Timestampable: ~ }
  columns:
    name:    { type: string(255), notnull: true, unique: true }
    famille: { type: string(255), notnull: true, unique: true }
Valeurs:
  actAs: { Timestampable: ~ }
  columns:
    Annonce_id:           { type: integer, notnull: true }
    TypeParticulier_id:   { type: integer, notnull: true }
    nom:                  { type: string(255), notnull: true, unique: true }
  relations:   
    Annonce:          { onDelete: CASCADE, local: Annonce_id, foreign: id }
    TypeParticulier:  { onDelete: CASCADE, local: TypeParticulier_id, foreign: id }
 
Photo:
  actAs: { Timestampable: ~ }
  columns:
    Annonce_id:  { type: integer, notnull: true }
    filename:    { type: string(255) }
    caption:     { type: string(255), notnull: true }
  relations:   
    Annonce:     {alias:Annonce,foreignType:  many,foreignAlias: Photos, onDelete: CASCADE }
J'aimerais intégrer deux champs avec une liste déroulante qui contiennent les régions et les départements dans le formulaire ANNONCE mais il reconnait pas le champs "name" de la table Region.



AnnonceForm :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
class AnnonceForm extends BaseAnnonceForm
{
public function configure()
  {
 
    unset(
       $this['Utilisateur_id'],$this['created_at'], $this['updated_at'],
      $this['expires_at'], $this['is_activated'],$this['isAccomplished']
    );
 
 
  $this->embedRelation('Region');
   $this->embedRelation('Annonce');
 
}
Mon _form.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
<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
 
<?php echo form_tag_for($form, '@ads') ?>
  <table id="job_form">
    <tfoot>
      <tr>
        <td colspan="2">
          <input type="submit" value="Preview your ad" />
        </td>
      </tr>
    </tfoot>
    <tbody>
      <?php echo $form['Categorie_id']->renderRow() ?>
 
     <!-- <?php// echo $form['Region_id']->renderRow() ?>
	  <?php// echo $form['Departement_id']->renderRow() ?> --!> 
 
	  <?php echo $form['Region']['Name']->renderRow() ?> <?php //bug ?>
 
	  <?php echo $form['CodePostal']->renderRow() ?>
	  <?php echo $form['Ville']->renderRow() ?>
	  <?php echo $form['TypeAnnonce']->renderRow() ?>
	  <?php echo $form['TitreAnnonce']->renderRow() ?>
	  <?php echo $form['TexteAnnonce']->renderRow() ?>
	  <?php echo $form['Prix']->renderRow() ?>
	  <?php echo $form->renderHiddenFields() ?>
	  <?php foreach ($form['newPhotos'] as $photo): ?>
      <?php echo $photo['caption']->renderRow() ?>
      <?php echo $photo['filename']->renderRow() ?>
      <?php endforeach; ?>
 
    </tbody>
  </table>
</form>

Est-ce la bonne façon de faire ?


Merci
fastone650 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h48.


 
 
 
 
Partenaires

Hébergement Web