Bonjour,
J'ai créé un url pour créer un nouveau "comment" avec l'id du "contact".
Le CommentForm est lancé:/frontend_dev.php/comment/new/id/2
Et voilà mon executeNew:
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 class CommentForm extends BaseCommentForm { public function configure() { $this->setWidgets(array( 'id' => new sfWidgetFormInputHidden(), 'contact' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('contact'), 'add_empty' => false)), 'comment' => new sfWidgetFormInputText(), )); $this->setValidators(array( 'id' => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)), 'contact' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('contact'))), 'comment' => new sfValidatorString(array('max_length' => 255)), )); } }Dans la class Contact, j'ai ajouté le __toString(). J'obtiens bien une liste des différents contacts lorsque je lance l'url New
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 public function executeNew(sfWebRequest $request) { $this->form = new CommentForm(); }
Question: Je ne trouve comment sélectionner l'utilisateur de cette liste avec l'id dans l'url.
Partager