我遇到yii-CJuiAutoComplete的问题。必填字段仅适用于一个字段。在模型中添加了必需的规则。但它不起作用。它是我的_form.php
<div class="form-group">
<?php echo $form->labelEx($model,'collegename',array('class'=>'col-sm-3 control-label')); ?>
<div class="col-sm-9">
<?php
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'model'=>$form,
'name'=>'collegename',
'source'=>$this->createUrl('controller/action'),
// additional javascript options for the autocomplete plugin
'options'=>array(
'showAnim'=>'fold',
),
'htmlOptions'=>array(
// 'style'=>'height:20px;',
'class'=>'span5 form-control',
'placeholder'=>'College Name',
//'style' => 'text-transform: uppercase'
),
));
?>
<?php echo $form->error($model,'collegename'); ?>
</div>
</div>
模型
array('collegename', 'required'),
答案 0 :(得分:0)
您传递的是表单而不是模型。 尝试:
<?php
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'model'=>$model,
'attribute'=>'collegename',
'source'=>$this->createUrl('controller/action'),
// additional javascript options for the autocomplete plugin
'options'=>array(
'showAnim'=>'fold',
),
'htmlOptions'=>array(
// 'style'=>'height:20px;',
'class'=>'span5 form-control',
'placeholder'=>'College Name',
//'style' => 'text-transform: uppercase'
),
));
?>