如何在Yii框架中单击按钮添加子选项卡? [英] How to add child tab onclick of button in Yii framework?

查看:25
本文介绍了如何在Yii框架中单击按钮添加子选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助在 Yii 框架中实现这一点.单击此添加按钮(如图所示的 + 按钮)需要创建更多选项卡.

Please help to achieve this in Yii framework. onclick of this add button(+ button as showned in image) need to create more tabs.

我可以在我的 View 类中使用以下代码来显示标签

I can display tabs by using following code in my View class

 <?php 
   $this->widget('CTabView', array(
    'tabs'=>array(
        'tab1'=>array(
            'title'=>'Tab1',
            'view'=>'tabs',
            'data'=>array('model'=>BCFormField::model(),),
        ),
)
 )));
?>

但是让我知道如何添加更多 chiltab,点击这个 + 按钮.

But let me know how to add more chiltab, onclick of this + button.

推荐答案

我建议通过触发选项卡的可见性来棘手地添加选项卡.事先根据需要创建尽可能多的选项卡(例如 30),并在特定条件下设置它们的可见性(例如 db 字段).然后单击您更改关键字段/变量并显示一个选项卡.

I suggest to tricky add tabs by triggering tabs' visibility. Create as many as needed tabs (ex. 30) beforehand and set their visibility on certain condition (db field for ex.). Then on click you change the key field/variable and a tab gets visible.

看我的案例:

    'tab7'=>array(
        'title'=>Yii::t('general', 'Products / Services'),
        'view'=>'_form_ordercontent',
        'data'=>array('eventId'=>$model->Id),
    'visible' => $model->EventTypeId == DocEvents::TYPE_ORDER || $model->EventTypeId == DocEvents::TYPE_INFLOW || $model->EventTypeId == DocEvents::TYPE_SALE
    ),
    'tab8'=>array(
        'title'=>'Payment',
        'view'=>'_form_payment',
        'data'=>array('model'=>$model, 'eventId'=>$model->Id),
     'visible' => Yii::app()->user->checkAccess('1');
    ),

因此,当您按下按钮时,某些变量(或模型属性)会发生更改并且相应的选项卡会暴露出来,它们的内容将被预定义它适合你的情况吗?

So as you push button certain variable (or model attribute) gets changed and corresponding tabs get exposed, their content being predefined Does it fit your case?

这篇关于如何在Yii框架中单击按钮添加子选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆