问题描述:

I want to create a form in yii with a checkboxlist populated by a related data. The form is the following :

<div class="form">

<?php

$form = $this->beginWidget('GxActiveForm', array(

'id' => 'groupeAdd-form',

'enableAjaxValidation' => true,

));

?>

<?php echo $form->errorSummary($model); ?>

<div class="row">

<?php echo $form->textField($model, 'id_groupe', array('hidden' => true, 'value' => $_GET['id'])); ?>

</div>

<div class="row">

<label><?php

echo "Sélectionner les contacts à ajouter";

?>

</label>

<?php echo $form->checkBoxList($model, 'id_contact', GxHtml::encodeEx(GxHtml::listDataEx(Contact::model()->findAllAttributes(null, true)), true, true)); ?>

</div>

<?php echo GxHtml::submitButton(Yii::t('app', 'Ajouter')); ?>

<?php $this->endWidget(); ?>

</div>

But when sending the form, I get an exception.

Please fix the following input errors:

Id Contact must be a number.

Looking at the source code of my HTML file, I remarked a hidden input field which may be at the origin of the problem. How to remove this field, if it is the solution? Please help.

This is the result of $_REQUEST dump.

The content of the file is the following, as I checked all the boxes :

Array

(

[r] => groupe/AddMember

[id] => 1

[EtreMembre] => Array

(

[id_groupe] => 1

[id_contact] => Array

(

[0] => 1

[1] => 2

[2] => 3

)

)

[yt0] => Ajouter

)

相关阅读:
Top