Yii封装级联select,多次用到,总结一些,直接代码

都是个人经验封装,多次用到,没有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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值