Validation form de sfWidgetFormChoice
Bonjour,
j'ai un souci avec la validation de ma form qui comporte plusieurs sfWidgetForm choice :
Voici ma form:
Code:
1 2 3 4 5 6 7 8 9
|
$this->setWidgets(array('produit' => new sfWidgetFormChoice(array('choices'=> $produits, 'multiple' => true, 'expanded' => false)),
'gravite' => new sfWidgetFormChoice(array('choices'=> $gravite, 'multiple' => true, 'expanded' => false))));
$this->validatorSchema['produit'] = new sfValidatorChoice(array('multiple' => true,'choices'=> $produits),array('required' => 'Sélectionner au moins un produit.'));
$this->validatorSchema['gravite'] = new sfValidatorChoice(array('multiple' => true,'choices'=> $gravite),array('required' => 'Sélectionner au moins une Gravité.')); |
Mon action :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
$this->form = new StatForm();
if($request->isMethod('post')){
$this->form->bind(array('produit' => $request->getParameter('produit')),
array('gravite' => $request->getParameter('gravite'))
);
if ($this->form->isValid())
{
...... |
j'ai deux type d'erreur selon la combinaison dans le choix :
1 - Unexpected extra form field named "gravite". respectivement "produit"
2 - Warning: array_keys() [function.array-keys]: The first argument should be an array in ..\lib\vendor\symfony\lib\form\sfForm.class.php on line 1237
Warning: sort() expects parameter 1 to be array, null given in ...\lib\form\sfForm.class.php on line 1238
J'ai des doutes sur le fonctionnement de bind() !!!
Merci pour votre aide :ccool: