下拉框数据生成
  • 模型里选择数据

    public static function getTypeList()
        {
            $list=self::where(true)->select();
            $res=[];
            foreach ($list as $k=>$v){
                $res[$v['id']]=$v['name'];
            }
            return $res;
        }
    
  • 控制器的渲染数据

    public function _initialize()
        {
            parent::_initialize();
            $this->model = new \app\admin\model\yuyue\Schedule;
            $this->view->assign("TypeList", NewchatType::getTypeList());
        }
    
  • html里显示数据

    <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">{:__('Typeid')}:</label>
            <div class="col-xs-12 col-sm-8">
    
                <select  >
                    {foreach name="TypeList" item="vo"}
                        <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
                    {/foreach}
                </select>
    
            </div>
        </div>
    

相关文章:

  • 2022-12-23
  • 2021-11-09
  • 2021-11-19
  • 2021-11-29
  • 2021-11-08
  • 2022-12-23
  • 2021-11-17
  • 2022-01-24
猜你喜欢
  • 2021-06-02
  • 2021-11-09
  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案