我有一段以下代码:
form->field($website, 'clients_id', [
'template' => "{label}<div class='col-md-9'>{input}</div>\n{hint}\n{error}"
])
->listBox($dataList, [
'data-placeholder' =>'Choose one..',
'class' => 'select-select2',
'style' => 'width: 100%',
'id' => 'example-select2'
])
->label('Clients')
在网站模型中仍然会返回“clients_id”字段的错误验证。但是在视图中没有显示错误
虽然在开发工具中我仍然看到这个标签
<div class="help-block help-block-error "></div>
---更新---
在我的模型中:
public function rules()
{
return [
[['domain', 'clients_id', 'online_date'], 'required'],
[['online_date', 'created_at', 'updated_at'], 'safe'],
[['active', 'clients_id'], 'integer'],
[['domain'], 'string', 'max' => 255]
];
}
当我打印错误验证时
array(1) {["clients_id"]=> array(1) {[0]=> string(27) "Clients ID cannot be blank." }}
- 视图中的ActiveForm设置---
<?php
$form = ActiveForm::begin([
'id' => 'web-form',
'layout' => 'horizontal',
'options' => [
'class' => 'form-horizontal form-bordered',
'enctype' => 'multipart/form-data'
],
'fieldConfig' => [
'horizontalCssClasses' => [
'label' => 'col-md-3 control-label',
],
],
]);
?>
由于