Yii框架 - 填充checkBoxList

时间:2014-09-08 09:24:56

标签: php yii checkboxlist

我想在yii中创建一个表单,其中包含一个由相关数据填充的checkboxlist。表格如下:

<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>

但是在发送表单时,我得到了一个例外。

Please fix the following input errors:
Id Contact must be a number.

查看我的HTML文件的源代码,我注意到一个隐藏的input字段,它可能是问题的根源。如果是解决方案,如何删除此字段?请帮忙。

这是$_REQUEST转储的结果。

当我检查所有方框时,文件的内容如下:

Array
(
[r] => groupe/AddMember
[id] => 1
[EtreMembre] => Array
    (
        [id_groupe] => 1
        [id_contact] => Array
            (
                [0] => 1
                [1] => 2
                [2] => 3
            )

    )

   [yt0] => Ajouter
)

0 个答案:

没有答案
相关问题