Bonjour,
Je cherche à personnaliser l'affichage de mon $form
Dans mon partial, j'ai un $form avec un bouton save.
Si je fais:
Code : Sélectionner tout - Visualiser dans une fenêtre à part echo $form;J'ai un message d'erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 echo $form['id']->renderRow(); echo $form['contactid']->renderRow(); echo $form['comment']->renderRow(array('rows' => '10', 'cols' =>'50'), 'Commentaire');
Code : Sélectionner tout - Visualiser dans une fenêtre à part Undefined variable: contact in .../newSuccess.php on line 6
mas Basecomment Form:et mon configure:
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 abstract class BasecommentForm extends BaseFormDoctrine { public function setup() { $this->setWidgets(array( 'id' => new sfWidgetFormInputHidden(), 'contactid' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('contact'), 'add_empty' => false)), 'comment' => new sfWidgetFormTextarea(), 'created_at' => new sfWidgetFormDateTime(), 'updated_at' => new sfWidgetFormDateTime(), )); $this->setValidators(array( 'id' => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)), 'contactid' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('contact'))), 'comment' => new sfValidatorString(array('max_length' => 65535)), 'created_at' => new sfValidatorDateTime(), 'updated_at' => new sfValidatorDateTime(), )); $this->widgetSchema->setNameFormat('comment[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); $this->setupInheritance(); parent::setup(); }
Question annexe:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 class CommentForm extends BaseCommentForm { public function configure() { unset( $this['created_at'], $this['updated_at'] ); //$this->setWidget('contactid', new sfWidgetFormInputHidden()); } }
Avec le echo $form, les sfWidgetFormInputHidden() ne sont pas affichés. Avec renderRow() cela affiche le label. Mon but étant de bien de créer un champ caché au travers de renderRow().
Partager