从TbForm迁移到TbActiveForm yiibooster

Hi,

I recently was given a task to update our yiibooster extension.

The issue I'm having is that this tbform code no longer works in this version of yiibooster (the entire tbform functionality seems to have been removed)

 $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;

My guess to rebuilding the functionality for this would be but I'm getting no luck in having it actually work. (tbactiveform.0 is not defined)

$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;

Start by simply doing something like:

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

Build from here. If above code gives you error let me know, I'm sure we can work it out :). Also notice that you are giving too many param's in beginWidget function:

$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
                        )
                    );       

Here you have like 4 parameters while

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

takes only two.