簡體   English   中英

從TbForm遷移到TbActiveForm yiibooster

[英]Migrating from TbForm to TbActiveForm yiibooster

你好

最近,我接到了更新yiibooster擴展程序的任務。

我遇到的問題是,此tbform代碼在此版本的iiiibooster中不再起作用(整個tbform功能似乎已被刪除)

 $sessionForm = new SessionSelectionForm();

         $items = $dataModel->getDynamicFormSessionsConfig($sessionForm);

         $form = TbForm::createForm(
                        array(
                    'title' => 'Session Registration',
                    'enableClientValidation' => true,
                    'enableAjaxValidation' => false, // Just keep this to false
                    'layout' => TbHtml::FORM_LAYOUT_HORIZONTAL,
                    'elements' => $items,
                     'buttons' => array(
                         'reset' => array(
                             'type' => 'reset',
                             'label' => 'Reset',
                         ),
                         'submit' => array(
                             'type' => 'submit',
                             'label' => 'Next',
                             'layoutType' => 'primary'
                         ),
 //                        'cancel' => array(
 //                            'type' => 'submit',
 //                            'label' => 'Cancel',
 //                            'layoutType' => 'warning'
 //                        ),
                     ),
                         ), null, array(
                     'htmlOptions' => array('class' => 'well'),
                     'type' => 'horizontal',
                         ), $sessionForm
         );
         return $form;

我的猜測是要為此重建功能,但要使它真正起作用我並不走運。 (未定義tbactiveform.0)

$sessionForm = new SessionSelectionForm();

         $items = $dataModel->getDynamicFormSessionsConfig($sessionForm);

$form = $this->beginWidget(
                    'booster.widgets.TbActiveForm',
                        array(
                            // 'title' => 'Session Registration',
                            'enableClientValidation' => true,
                            'enableAjaxValidation' => false, // Just keep this to false
                            // 'layout' => TbHtml::FORM_LAYOUT_HORIZONTAL,
                            'htmlOptions' => array(
                                    'type' => 'horizontal',
                                    'data' => $items,
                                    ),
                                    null,  $sessionForm
                            )
                        );                                          // 'elements' => $items,
                        $this->widget(
                             'booster.widgets.TbButtonGroup',
                                array(
                                    'buttons' => array(
                                        array('label' => 'reset', 'buttonType' => 'reset'),
                                        array('label' => 'next', 'buttonType' => 'submit'),
                                    ),
                                )                
                        );
            $this->endWidget();
            return $form;

從簡單地做類似的事情開始:

$form = $this->beginWidget( 'booster.widgets.TbActiveForm', array(
        'id'                    => 'contents-form',
        'enableAjaxValidation'  => true,
    ) );

從這里建造。 如果上述代碼給您帶來錯誤,請告訴我,我確定我們可以解決:)。 還要注意,在beginWidget函數中給了太多的參數:

$form = $this->beginWidget(
                'booster.widgets.TbActiveForm',
                    array(
                        // 'title' => 'Session Registration',
                        'enableClientValidation' => true,
                        'enableAjaxValidation' => false, // Just keep this to false
                        // 'layout' => TbHtml::FORM_LAYOUT_HORIZONTAL,
                        'htmlOptions' => array(
                                'type' => 'horizontal',
                                'data' => $items,
                                ),
                                null,  $sessionForm
                        )
                    );       

在這里,您有4個參數,而

public function beginWidget($className,$properties=array()) {

只需要兩個。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM