Active Form

Yii Active Forms on steroids. Heavy ones.

Here's all configuration properties which you can set for TbActiveForm widget.

Property Description
type name = default description

Vertical

/** @var TbActiveForm $form */
$form = $this->beginWidget(
    'bootstrap.widgets.TbActiveForm',
    array(
        'id' => 'verticalForm',
        'htmlOptions' => array('class' => 'well'), // for inset effect
    )
);

echo $form->textFieldRow($model, 'textField', array('class' => 'span3'));
echo $form->passwordFieldRow($model, 'password', array('class' => 'span3'));
echo $form->checkboxRow($model, 'checkbox');
$this->widget(
    'bootstrap.widgets.TbButton',
    array('buttonType' => 'submit', 'label' => 'Login')
);

$this->endWidget();
unset($form);

Search Form

/** @var TbActiveForm $form */
$form = $this->beginWidget(
    'bootstrap.widgets.TbActiveForm',
    array(
        'id' => 'searchForm',
        'type' => 'search',
        'htmlOptions' => array('class' => 'well'),
    )
);
echo $form->textFieldRow(
    $model,
    'textField',
    array(
        'class' => 'input-medium',
    ),
    array(
        'prepend' => '<i class="icon-search"></i>'
    )
);
$this->widget(
    'bootstrap.widgets.TbButton',
    array('buttonType' => 'submit', 'label' => 'Go')
);

$this->endWidget();
unset($form);

Inline Form

/** @var TbActiveForm $form */
$form = $this->beginWidget(
    'bootstrap.widgets.TbActiveForm',
    array(
        'id' => 'inlineForm',
        'type' => 'inline',
        'htmlOptions' => array('class' => 'well'),
    )
);

echo $form->textFieldRow($model, 'textField', array('class' => 'input-small'));
echo $form->passwordFieldRow(
    $model,
    'password',
    array('class' => 'input-small')
);
$this->widget(
    'bootstrap.widgets.TbButton',
    array('buttonType' => 'submit', 'label' => 'Log in')
);

$this->endWidget();
unset($form);

Here's the showcase of almost all input types applicable to TbActiveForm, set into the horizontal-style form.

Legend
<?php /** @var TbActiveForm $form */
$form = $this->beginWidget(
    'bootstrap.widgets.TbActiveForm',
    array(
        'id' => 'horizontalForm',
        'type' => 'horizontal',
    )
); ?>

    <fieldset>

        <legend>Legend</legend>

        <?php echo $form->textFieldRow(
            $model,
            'textField',
            array('hint' => 'In addition to freeform text, any HTML5 text-based input appears like so.')
        ); ?>
        <?php echo $form->datepickerRow(
            $model,
            'dateField',
            array(
                'options' => array(
                    'language' => 'es',
                ), 
                'htmlOptions' => array(
                    'hint' => 'Click inside! This is a super cool date field.',
                )
            ),
            array(
                'prepend' => '<i class="icon-calendar"></i>'
            )
        ); ?>
        <?php echo $form->dateRangeRow(
            $model,
            'dateRangeField',
            array(
                'htmlOptions' => array(
                    'hint' => 'Click inside! An even a date range field!.',
                ),
                'callback' => 'js:function(start, end){console.log(start.toString("MMMM d, yyyy") + " - " + end.toString("MMMM d, yyyy"));}'
            ), 
            array(
                'prepend' => '<i class="icon-calendar"></i>',
            )
        ); ?>
        <?php echo $form->timepickerRow(
            $model,
            'timepicker',
            array(
                'htmlOptions' => array(
                    'hint' => 'Nice bootstrap time picker',
                    'class' => 'input-small',
                )
            )
        ); ?>
        <?php echo $form->colorpickerRow(
            $model,
            'colorpicker',
            array(
                'htmlOptions' => array(
                    'hint' => 'Color fields, not bad',
                )
            )
        ); ?>
        <?php echo $form->dropDownListRow(
            $model,
            'dropdown',
            array('Something ...', '1', '2', '3', '4', '5')
        ); ?>
        <?php echo $form->dropDownListRow(
            $model,
            'multiDropdown',
            array('1', '2', '3', '4', '5'),
            array('multiple' => true)
        ); ?>
        <?php echo $form->select2Row(
            $model,
            'select2',
            array(
                'asDropDownList' => false,
                'options' => array(
                    'tags' => array('clever', 'is', 'better', 'clevertech'),
                    'placeholder' => 'type clever, or is, or just type!',
                    'width' => '40%',
                    'tokenSeparators' => array(',', ' ')
                )
            )
        );?>
        <?php echo $form->fileFieldRow($model, 'fileField'); ?>
        <?php echo $form->textAreaRow(
            $model,
            'textarea',
            array('class' => 'span4', 'rows' => 5)
        ); ?>
        <?php echo $form->redactorRow(
            $model,
            'redactor',
            array(
                'editorOptions' =>array(
                    'class' => 'span4', 
                    'rows' => 5, 
                    'options' => array('plugins' => array('clips', 'fontfamily'), 'lang' => 'sv')
                )
            )
        ); ?>
        <?php echo $form->html5EditorRow(
            $model,
            'wysihtml5',
            array(
                'editorOptions' => array(
                    'class' => 'span4',
                    'rows' => 5,
                    'height' => '200',
                    'options' => array('color' => true)
                )
            )
        ); ?>
        <?php echo $form->ckEditorRow(
            $model,
            'ckeditor',
            array(
                'editorOptions' => array(
                    'fullpage' => 'js:true',
                    'width' => '640',
                    'resize_maxWidth' => '640',
                    'resize_minWidth' => '320'
                )
            )
        ); ?>
        <?php echo $form->markdownEditorRow(
            $model,
            'markdown',
            array('height' => '200px')
        ); ?>
        <?php echo $form->toggleButtonRow($model, 'toggle'); ?>
        <?php echo $form->textFieldRow(
            $model,
            'disabled',
            array('disabled' => true)
        ); ?>
        <?php echo $form->textFieldRow(
            $model,
            'prepend',
            array('prepend' => '@')
        ); ?>
        <?php echo $form->textFieldRow(
            $model,
            'append',
            array('append' => '.00')
        ); ?>
        <?php echo $form->checkBoxRow(
            $model,
            'disabledCheckbox',
            array('disabled' => true)
        ); ?>
        <?php echo $form->checkBoxListRow(
            $model,
            'inlineCheckboxes',
            array('1', '2', '3')
        ); ?>
        <?php echo $form->checkBoxListRow(
            $model,
            'checkboxes',
            array(
                'Option one is this and that - be sure to include why it\'s great',
                'Option two can also be checked and included in form results',
                'Option three can - yes, you guessed it - also be checked and included in form results',
            ),
            array('hint' => '<strong>Note:</strong> Labels surround all the options for much larger click areas.')
        ); ?>
        <?php echo $form->radioButtonRow($model, 'radioButton'); ?>
        <?php echo $form->radioButtonListRow(
            $model,
            'radioButtons',
            array(
                'Option one is this and that - be sure to include why it\'s great',
                'Option two can is something else and selecting it will deselect option one',
            )
        ); ?>
    </fieldset>

    <div class="form-actions">
        <?php $this->widget(
            'bootstrap.widgets.TbButton',
            array(
                'buttonType' => 'submit',
                'type' => 'primary',
                'label' => 'Submit'
            )
        ); ?>
        <?php $this->widget(
            'bootstrap.widgets.TbButton',
            array('buttonType' => 'reset', 'label' => 'Reset')
        ); ?>
    </div>
<?php
$this->endWidget();
unset($form);