Bonjour,
Je n'arrive pas à trouver l'information (fonction?) pour ajuster ma classe BasecommentForm au travers du configure de ma classe commentForm.
Ce que je fais: je réécris les composants de ma classe BasecommentForm dans commentForm.
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 public function setup() { $this->setWidgets(array( 'id' => new sfWidgetFormInputHidden(), 'contact_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('contact'), 'add_empty' => true)), 'etio_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('etios'), 'add_empty' => false)), 'content' => 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)), 'contact_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('contact'), 'required' => false)), 'etio_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('etios'))), 'content' => new sfValidatorString(array('max_length' => 20000, 'required' => false)), 'created_at' => new sfValidatorDateTime(), 'updated_at' => new sfValidatorDateTime(), )); $this->widgetSchema->setNameFormat('comment[%s]'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); $this->setupInheritance(); parent::setup(); }Comment ajouter des paramètres pour les widgets déjà créés dans Base? Admettons que je veuille mettre 'add_empty' à "true" ou ajouter d'autres paramètres.
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
29 public function configure() { $this->setWidgets(array( 'id' => new sfWidgetFormInputHidden(), 'contact_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('contact'), 'add_empty' => true)), 'etio_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('etios'), 'add_empty' => false)), 'content' => 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)), 'contact_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('contact'), 'required' => false)), 'etio_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('etios'))), 'content' => new sfValidatorString(array('max_length' => 20000, 'required' => false)), 'created_at' => new sfValidatorDateTime(), 'updated_at' => new sfValidatorDateTime(), )); unset( //$this['contact_id'], $this['created_at'], $this['updated_at'] ); }
En plus en faisant ce qu'il y a dessus j'ai un comportement différent lors de l'enregistrement dans mon formulaire (un "required" est levé sans apparente raison).
Merci d'avance !
Partager