Class kartik\form\ActiveForm
| Inheritance | kartik\form\ActiveForm » yii\widgets\ActiveForm |
|---|---|
| Available since version | 1.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
| Property | Type | Description | Defined 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
| Method | Description | Defined 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
| Method | Description | Defined By |
|---|---|---|
| initForm() | Initializes the form configuration array and parameters for the form. | kartik\form\ActiveForm |
Constants
| Constant | Value | Description | Defined 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
Whether all inputs in form are to be disabled
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 thehint()method.[ 'labelSpan' => 2, 'deviceSize' => ActiveForm::SIZE_MEDIUM, 'showLabels' => true, 'showErrors' => true, 'showHints' => true ],
Set the bootstrap grid width. Defaults to kartik\form\ActiveForm::FULL_SPAN.
Whether all inputs in form are to be readonly
Whether all data in form are to be static inputs
Form orientation type (for bootstrap styling) Defaults to 'vertical'.
Method Details
| public void getFormLayoutStyle ( ) |
Gets input css property
| public string getInputCss ( ) |
Gets label css property
| public string getLabelCss ( ) |
Gets offset css property
| public string getOffsetCss ( ) |
Checks if input css property is set
| public bool hasInputCss ( ) |
Checks if offset css property is set
| public bool hasOffsetCss ( ) |
Initializes the widget.
| public void init ( ) | ||
| throws | \yii\base\InvalidConfigException | |
|---|---|---|
Initializes the form configuration array and parameters for the form.
| protected void initForm ( ) |
Registers the needed assets
| public void registerAssets ( ) |
Sets input css property
| public void setInputCss ( $class ) | ||
| $class | string | |
Sets label css property
| public void setLabelCss ( $class ) | ||
| $class | string | |
Sets offset css property
| public void setOffsetCss ( $class ) | ||
| $class | string | |