PHP code example of quansitech / qscmf-columntype-modal
1. Go to this page and download the library: Download quansitech/qscmf-columntype-modal library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
quansitech / qscmf-columntype-modal example snippets
composer
> // 可以与formBuilder结合使用,展示渲染后的html
> public function genModelHtml($id){
> $info = D('Post')->getOne($id);
> $builder = new FormBuilder();
> $builder
> ->addFormItem('title', 'text', '标题')
> ->addFormItem('summary', 'textarea', '简介')
> ->addFormItem('cover', 'picture', '封面', '尺寸为214*250px', ['width' => 214, 'height' => 250])
> ->setFormData($info)
> ->setShowBtn(false)
> ->setReadOnly(true);
>
> return $builder->display(true);
> }
>
> $data_list = D('User')->limit(10)->select();
> foreach ($data_list as &$v){
> $v['modal_html'] = $this->genModelHtml($v['post_id']);
> }
>
> // 当value为数组
> ->addTableColumn('nick_name', '用户名', 'modal', ['content' => '__modal_html__'], false, '点击查看更多信息')
>
> //当value为字符串
> ->addTableColumn('nick_name', '用户名', 'modal', '__modal_html__', false, '点击查看更多信息')
>
> // api_url的参数支持使用占位符,动态替换list的值
> // 如列id,只需用 __id__ 作为占位符,生成list后会自动替换成该记录的真实id值。
> // 若列名存在下划线,如user_id,那么占位符就是 __user_id__ ,以此类推。
> $option = [
> 'api_url' => U('genModelHtml', ['id'=>'__id__'], true, true),
> 'width' => '50%',
> 'height' => '50%'
> ];
>
> // ListBuilder对应列配置
> ->addTableColumn('nick_name', '用户名', 'modal', $option, false, '点击查看更多信息');
>
> public function genModelHtml($id){
> $info = D('User')->getOne($id);
>
> if (!$info){
> $this->ajaxReturn(['status' => 0, 'info' => 'not found']);
> }
> $builder = new FormBuilder();
> $builder
> ->addFormItem('title', 'text', '标题')
> ->addFormItem('summary', 'textarea', '简介')
> ->addFormItem('cover', 'picture', '封面', '尺寸为214*250px', ['width' => 214, 'height' => 250])
> ->setFormData($info)
> ->setShowBtn(false)
> ->setReadOnly(true);
>
> $this->ajaxReturn(['status' => 1, 'info' => $builder->display(true)]);
>}
>
>$option = [
> 'content' => 'modal content',
> 'width' => '50%',
> 'height' => '50%'
>];
>
>->addTableColumn('nick_name', '用户名', 'modal', $option, false, '点击查看更多信息')
>