bonjour, j ai un petit soucis je m'arrrache les cheveux avec ça.. j ai un formulaire sous symfony avec des input type radio , tout fonctionne mais le problème lors de la récupération des valeurs je récupère les keys au lieu de la valeur je ne comprends pas d'ou vient le pb ..


ci joint mon form.class

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
30
31
32
33
34
35
36
37
38
 
static protected $choices1 = array(
'Tres interessant',
'interessant',
'je ne connais pas cette rubrique',
'pas interessant'
  );
static protected $choices2 = array(
'Tres facile',
'facile',
 'difficile',
'tres difficile'
  );
static protected $choices3 = array(
'Tres claires',
'claires',
'compliquees',
'tres compliquees'
  );
 
  public function configure()
  {
  	$this->widgetSchema['test']  = new sfWidgetFormSelectRadio(array('choices'  => self::$choices1));
 
  	$this->widgetSchema['navigation']  = new sfWidgetFormSelectRadio(array('choices'  => self::$choices2));
 
  	$this->widgetSchema['informations']   = new sfWidgetFormSelectRadio(array('choices'  => self::$choices3));
 
	$this->widgetSchema['avis'] = new sfWidgetFormTextarea();
 
	$this->setValidators(array(
			'test'         => new sfValidatorChoice(array('required' => true,'choices' => array_keys(self::$choices1))),
                        'navigation'      => new sfValidatorChoice(array('required' => true,'choices' => array_keys(self::$choices2))),
			'informations'       => new sfValidatorChoice(array('required' => true,'choices' => array_keys(self::$choices3))),
                        'avis'   => new sfValidatorString(array('min_length' => 4))
    	));
	unset($this['id']);
  }
et mon action :


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
30
31
 
public function executeFormulaireW(dmWebRequest $request)
  {
    $form = new TestForm();
 
    if ($request->isMethod('post')) {
       $form->bind($request->getParameter($form->getName()));
 
     if ($form->isValid()) {
 
      $form->save();
       //send mail here
                dm::enableMailer();
 
                $this->getService('mail')->setTemplate('mail_test')
                        ->addValues(array(// add values to populate the template  
                            'nom' => htmlentities($nom, ENT_QUOTES),
			    'prenom' => htmlentities($prenom, ENT_QUOTES),
                            'user_email' => htmlentities($email, ENT_QUOTES),
			    'test' => $form->getValue('test'),
			    'navigation' => $form->getValue('navigation'),
			    'informations' => $form->getValue('informations'),
			    'avis' => htmlentities($form->getValue('avis'), ENT_QUOTES)
                        ))
                        ->send();
                $this->getUser()->setFlash('globalValid', 'Merci de votre participation.');
                $this->redirect('/');
      }
      $this->getUser()->setFlash('incomplete', 'Des champs sont incomplets ou invalides, merci de corriger ceux-ci.');
      $this->redirectBack();
    }
exemple $form->getValue('test') renvoit 1 si on coche intéressant

Merci de votre aide