我有小部件并在布局中调用它,为什么不重定向到站点/搜索?
<?php
class CSearch extends CWidget
{
public $model;
public function init()
{
$this->model = new SearchForm();
if(Yii::app()->request->isAjaxRequest && Yii::app()->request->getPost('FormSearch'))
{
$this->model->attributes = Yii::app()->request->getParam('FormSearch');
if($this->model->validate())
{
$this->owner->redirect(array('site/search', 'model' => $this->model->attributes));
}
}
}
public function run()
{
$this->render('search', array('model' => $this->model));
}
}
形式
<div class="header-search">
<?php $form = $this->beginWidget('CActiveForm', array(
'id' => 'search-form',
'enableAjaxValidation' => true,
'enableClientValidation' => true,
'clientOptions' => array(
'validateOnSubmit' => true,
'validateOnChange' => false,
'validateOnType' => false),
'htmlOptions' => array('class' => 'form-search'),
)); ?>
<?php echo $form->error($model, 'search'); ?>
<div class="input-append">
<?php echo $form->textField($model, 'search', array('class' => 'span2', 'placeholder' => 'Поиск')); ?>
<?php echo CHtml::htmlButton('<i class="icon-search"></i>', array('class' => 'btn', 'submit' => array('site/search')))?>
</div>
<?php $this->endWidget(); ?>
</div>
它是如何通过集团 Yii 正确验证的?对不起我的英语不好