规则中的要求不适用于yii2中的select2小部件

时间:2016-12-20 04:26:05

标签: php jquery yii2

我有两个下拉形式。我根据第一个下拉列表的值加载第二个下拉列表的值。 在模型中,我将第二个下拉列表指定为正常变量,但它得到了 输入多个选择。 我为第一次和第二次下拉写下了必要的验证。

模型

 */
    public function rules()
    {
        return [
            [['emp_id', 'role_team'], 'required'],
            [['emp_id', 'role_team'], 'integer'],
            [['status', 'team_status'], 'boolean'],
            [['type'], 'string']
        ];
    }

表格

<?php $form = ActiveForm::begin([
                'enableClientValidation'=>true,
                'enableAjaxValidation'=>true,
                'formConfig' => ['labelSpan' => 4,'showErrors'=>true,'showHints'=>true],]); ?>
<?php 
echo Form::widget([
                'model' => $model,
                'form' => $form,
                'columns'=>4,
                'attributes' => [
                'role_team' => ['type'=>Form::INPUT_WIDGET,
                'label'=>'Team',
                'widgetClass'=>'\kartik\select2\Select2',
                'options'=>['data'=>Teams::find()->select(['team_name'])->indexBy('team_id')->column(),'options'=>['placeholder'=>'Team Name','id'=>'team-category']]],
                'emp_id' => ['type'=>Form::INPUT_WIDGET,'label'=>'Employees',
                'widgetClass'=>'\kartik\select2\Select2',
                'options'=>['data'=> EmpDetails::find()->select(['emp_name'])->indexBy('emp_id')->column(),'options'=>['placeholder'=>'Employee Name','multiple'=>true,'id'=>'team-sub-category']]],
]
]);
?> 

在提交表单之前没有抛出错误。

0 个答案:

没有答案