TbHtml::formActions PHP Method

formActions() public static method

Generates form actions div. This is no longer necessary in Bootstrap 3, but it is still useful to use for horizontal forms. When used with a horizontal form, it will appropriately align the actions below other form controls.
public static formActions ( mixed $actions, array $htmlOptions = [] ) : string
$actions mixed the actions.
$htmlOptions array additional HTML attributes.
return string the generated actions.
    public static function formActions($actions, $htmlOptions = array())
    {
        self::addCssClass('form-actions', $htmlOptions);
        if (is_array($actions)) {
            $actions = implode(' ', $actions);
        }
        // todo: remove this
        $labelWidthClass = TbArray::popValue('labelWidthClass', $htmlOptions, self::$defaultFormLabelWidthClass);
        $controlWidthClass = TbArray::popValue('controlWidthClass', $htmlOptions, self::$defaultFormControlWidthClass);
        // todo: remove everything that has to do with form layout
        if (TbArray::popValue('formLayout', $htmlOptions, self::FORM_LAYOUT_VERTICAL) == self::FORM_LAYOUT_HORIZONTAL) {
            self::addCssClass(self::switchColToOffset($labelWidthClass), $htmlOptions);
            self::addCssClass(self::switchOffsetToCol($controlWidthClass), $htmlOptions);
            return self::tag('div', array('class' => 'form-group'), self::tag('div', $htmlOptions, $actions));
        } else {
            return self::tag('div', $htmlOptions, $actions);
        }
    }

Usage Example

Example #1
0
                <p class="text-center"><?php 
    echo Yii::t('app', 'Please input new password for ');
    ?>
                    <strong><?php 
    echo $model->username;
    ?>
</strong>

                    <?php 
    echo $form->errorSummary($model);
    ?>
                    <?php 
    echo $form->textFieldControlGroup($model, 'password', array('class' => 'span4', 'placeholder' => Yii::t('app', 'new password')));
    ?>

            </div>
            
            <?php 
    echo TbHtml::formActions([TbHtml::submitButton(Yii::t('app', 'Change password'), ['color' => TbHtml::BUTTON_COLOR_PRIMARY])]);
    ?>

        <?php 
}
?>

        <?php 
$this->endWidget();
?>
    </div>
</div><!-- form -->
All Usage Examples Of TbHtml::formActions
TbHtml