都是个人经验封装,多次用到,没有bug,下面直接代码
我放在组件中,封装的controller,还有封装中的视图一一对应
controller代码:
<?php
class SearchPSerise extends CWidget //继承Yii里面的类
{
protected $one_array = array(); //三级select,定义每个select的option数组
protected $two_array = array();
protected $three_array = array();
public $one_id = 0; //三级select,选中时的id,主要是为了点击查询后,有选中的checked值
public $two_id = 0;
public $three_id = 0;
public $one_field = 'one'; //三级select,定义每个select的id名
public $two_field = 'two';
public $three_field = 'three';
public $base_field = 'one_field'; //还原表单的关键字段
public $action = '';
public $is_form = true; //是否添加表单头尾
public $display_field = array('one_field', 'two_field', 'three_field');
public $sub_label = '查询';
public $htmlOptions = array(); //定义样式,多个options 样式
public $formHtmlOptions = array(); //定义form样式
public $submitHtmlOptions = array(); //定义submit样式
public function init()
{
$this->one_id = $this->one_id ? $this->one_id : Yii::app()->request->getParam($this->one_field, 0);
$this->two_id = $this->two_id ? $this->two_id : Yii::app()->request->getParam($this->two_field, 0); //获取id
$this->three_id = $this->three_id ? $this->three_id : Yii::app()->re