Class kartik\form\ActiveForm

Inheritancekartik\form\ActiveForm » yii\widgets\ActiveForm
Available since version1.0

Extends the ActiveForm widget to handle various bootstrap form types.

Example(s): `php // Horizontal Form $form = ActiveForm::begin([

 'id' => 'form-signup',
 'type' => ActiveForm::TYPE_HORIZONTAL

]); // Inline Form $form = ActiveForm::begin([

 'id' => 'form-login',
 'type' => ActiveForm::TYPE_INLINE
 'fieldConfig' => ['autoPlaceholder'=>true]

]); // Horizontal Form Configuration $form = ActiveForm::begin([

 'id' => 'form-signup',
 'type' => ActiveForm::TYPE_HORIZONTAL
 'formConfig' => ['labelSpan' => 2, 'deviceSize' => ActiveForm::SIZE_SMALL]

]);

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$disabled boolean Whether all inputs in form are to be disabled kartik\form\ActiveForm
$formConfig array The configuration for the form. kartik\form\ActiveForm
$fullSpan int Set the bootstrap grid width. kartik\form\ActiveForm
$readonly boolean Whether all inputs in form are to be readonly kartik\form\ActiveForm
$staticOnly boolean Whether all data in form are to be static inputs kartik\form\ActiveForm
$type string Form orientation type (for bootstrap styling) Defaults to 'vertical'. kartik\form\ActiveForm

Public Methods

Hide inherited methods

MethodDescriptionDefined By
getFormLayoutStyle() kartik\form\ActiveForm
getInputCss() Gets input css property kartik\form\ActiveForm
getLabelCss() Gets label css property kartik\form\ActiveForm
getOffsetCss() Gets offset css property kartik\form\ActiveForm
hasInputCss() Checks if input css property is set kartik\form\ActiveForm
hasOffsetCss() Checks if offset css property is set kartik\form\ActiveForm
init() Initializes the widget. kartik\form\ActiveForm
registerAssets() Registers the needed assets kartik\form\ActiveForm
setInputCss() Sets input css property kartik\form\ActiveForm
setLabelCss() Sets label css property kartik\form\ActiveForm
setOffsetCss() Sets offset css property kartik\form\ActiveForm

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
initForm() Initializes the form configuration array and parameters for the form. kartik\form\ActiveForm

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
DEFAULT_LABEL_SPAN 2 kartik\form\ActiveForm
FULL_SPAN 12 kartik\form\ActiveForm
NOT_SET '' kartik\form\ActiveForm
SCREEN_READER 'sr-only' kartik\form\ActiveForm
SIZE_LARGE 'lg' kartik\form\ActiveForm
SIZE_MEDIUM 'md' kartik\form\ActiveForm
SIZE_SMALL 'sm' kartik\form\ActiveForm
SIZE_TINY 'xs' kartik\form\ActiveForm
TYPE_HORIZONTAL 'horizontal' kartik\form\ActiveForm
TYPE_INLINE 'inline' kartik\form\ActiveForm
TYPE_VERTICAL 'vertical' kartik\form\ActiveForm

Property Details

$disabled public property

Whether all inputs in form are to be disabled

public boolean $disabled false
$formConfig public property

The configuration for the form. Takes in the following properties

  • labelSpan: int, the bootstrap grid column width (usually between 1 to 12)
  • deviceSize: string, one of the bootstrap sizes (refer the ActiveForm::SIZE constants)
  • showLabels: boolean|string, whether to show labels (true), hide labels (false), or display only for screen reader (ActiveForm::SCREEN_READER). This is mainly useful for inline forms.
  • showErrors: boolean, whether to show errors (true) or hide errors (false). This is mainly useful for inline forms.
  • showHints: boolean, whether to show hints (true) or hide errors (false). Defaults to true. The hint will be rendered only if a valid hint has been set through the hint() method.
    [
       'labelSpan' => 2,
       'deviceSize' => ActiveForm::SIZE_MEDIUM,
       'showLabels' => true,
       'showErrors' => true,
       'showHints' => true
    ],
    
public array $formConfig = []
$fullSpan public property

Set the bootstrap grid width. Defaults to kartik\form\ActiveForm::FULL_SPAN.

public int $fullSpan self::FULL_SPAN
$readonly public property

Whether all inputs in form are to be readonly

public boolean $readonly false
$staticOnly public property

Whether all data in form are to be static inputs

public boolean $staticOnly false
$type public property

Form orientation type (for bootstrap styling) Defaults to 'vertical'.

public string $type null

Method Details

getFormLayoutStyle() public method

public void getFormLayoutStyle ( )
getInputCss() public method

Gets input css property

public string getInputCss ( )
getLabelCss() public method

Gets label css property

public string getLabelCss ( )
getOffsetCss() public method

Gets offset css property

public string getOffsetCss ( )
hasInputCss() public method

Checks if input css property is set

public bool hasInputCss ( )
hasOffsetCss() public method

Checks if offset css property is set

public bool hasOffsetCss ( )
init() public method

Initializes the widget.

public void init ( )
throws \yii\base\InvalidConfigException
initForm() protected method

Initializes the form configuration array and parameters for the form.

protected void initForm ( )
registerAssets() public method

Registers the needed assets

public void registerAssets ( )
setInputCss() public method

Sets input css property

public void setInputCss ( $class )
$class string
setLabelCss() public method

Sets label css property

public void setLabelCss ( $class )
$class string
setOffsetCss() public method

Sets offset css property

public void setOffsetCss ( $class )
$class string