Extends and enhances the Yii ActiveForm widget. Facilitates all three form layouts available in Bootstrap i.e. vertical, horizontal, and inline. Allows options for offsetting labels and inputs for horizontal form layout. Works closely with the extended ActiveField component. In addition, this extension enhances and extends the Yii ActiveField component. Allows Bootstrap styled input group addons to be prepended or appended to textInputs. Implements feedback icons within inputs based on contextual states. Automatically adjusts checkboxes and radio input offsets for horizontal forms. Allows, flexibility to control the labels and placeholders based on form layout style (e.g. hide labels and show them as placeholder for inline forms). The extended ActiveField functionalities available are:
NOTE: This extension is a sub repo split of yii2-widgets. The split has been done since 08-Nov-2014 to allow developers to install this specific widget in isolation if needed. One can also use the extension the previous way with the whole suite of yii2-widgets.
The preferred way to install this extension is through composer. Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the minimum-stability
settings for your application's composer.json.
To install, either run
$ php composer.phar require kartik-v/yii2-widget-activeform "@dev"
or add
"kartik-v/yii2-widget-activeform": "@dev"
to the require
section of your composer.json
file.
NOTE: Refer the CHANGE LOG for details on changes to various releases.
You can refer detailed documentation and demos for understanding the usage of the extension at these links below:
// add this in your view
use kartik\form\ActiveForm;
// Vertical Form
$form = ActiveForm::begin([
'id' => 'form-signup',
'type' => ActiveForm::TYPE_VERTICAL
]);
// 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' => 3, 'deviceSize' => ActiveForm::SIZE_SMALL]
]);
// Implement a feedback icon
echo $form->field($model, 'email_2', [
'feedbackIcon' => [
'default' => 'envelope',
'success' => 'ok',
'error' => 'exclamation-sign',
'defaultOptions' => ['class'=>'text-primary']
]
])->textInput(['placeholder'=>'Enter a valid email address...']);
// Prepend an addon text
echo $form->field($model, 'email', ['addon' => ['prepend' => ['content'=>'@']]]);
// Append an addon text
echo $form->field($model, 'amount_paid', [
'addon' => ['append' => ['content'=>'.00']]
]);
// Formatted addons (like icons)
echo $form->field($model, 'phone', [
'addon' => [
'prepend' => [
'content' => '<i class="fas fa-phone"></i>'
]
]
]);
// Formatted addons (inputs)
echo $form->field($model, 'phone', [
'addon' => [
'prepend' => [
'content' => '<input type="radio">'
]
]
]);
// Formatted addons (buttons)
echo $form->field($model, 'phone', [
'addon' => [
'prepend' => [
'content' => Html::button('Go', ['class'=>'btn btn-primary']),
'asButton' => true
]
]
]);
yii2-widget-activeform is released under the BSD-3-Clause License. See the bundled LICENSE.md
for details.
yii2-widget-activeform
Date: 31-Jul-2023
parseFormFlag
method for readonly
and disabled
check.Date: 28-Jul-2023
enabled
, readonly
and staticOnly
flags.Date: 27-Feb-2022
Date: 13-Feb-2022
Date: 01-Sep-2021
Date: 01-Sep-2021
Date: 24-Feb-2019
Date: 27-Sep-2018
Date: 27-Sep-2018
Date: 26-Sep-2018
ActiveForm
methods isHorizontal
, isInline
, isVertical
for easy layout detection.Date: 22-Sep-2018
kartik\base\BootstrapInterface
. Date: 20-Sep-2018
Config::hasCssClass
.Date: 05-Sep-2018
addClass
assignment for HTML5 inputs.skipFormLayout
is set to true
.Date: 16-Aug-2018
Date: 16-Aug-2018
src
directory.Date: 05-Mar-2018
ActiveForm::field()
method.itemOptions
for checkboxButtonGroup
and radioButtonGroup
.$_pluginHintKeys
.formConfig
to be changed dynamically between ActiveForm::begin
and ActiveForm::end
and move getFormLayoutStyle
to ActiveFieldlabelSpan
and deviceSize
on level ActiveField alsolabelSpan
and deviceSize
Priority: 1. Option (fieldConfig),
horizontalCssClasses
compatible with yii/bootstrap/ActiveForm with
config options for wrapper
, label
, error
, hint
. These options give complete
control for all classes. labelSpan
still works and wrapper
is added if there
is no col-
tag defined.{beginWrapper
}, {endWrapper}
to enclose input, hint, error{label}
could be split into {beginLabel}
,
{labelTitle}
and {endLabel}
tag. {label}
is still working as usualActiveForm::fieldConfig
to be configured as Closure.Date: 28-Apr-2016
ActiveFormAsset
.Date: 05-Dec-2015
staticOnly
form render.HINT_DEFAULT
.Date: 05-Dec-2015
getAttributeLabel()
as default in initPlaceholder
.Date: 22-Oct-2015
checkboxButtonGroup
and radioButtonGroup
.Date: 08-Jul-2015
Date: 17-Jun-2015
Date: 11-May-2015
kv-fieldset-inline
.skipFormLayout
to override and skip special form layout styling.autoPlaceholder
property for INLINE forms when showLabels
is true
.showLabels
is ActiveForm:;SCREEN_READER
.enclosedByLabel
is false
.checkboxButtonGroup
& radioButtonGroup
in ActiveField.Date: 14-Feb-2015
control-label
class to labels for Vertical form.Date: 28-Jan-2015
staticValue
in ActiveField.ActiveField::staticInput
to include options to show error and hint.showHints
to true
for all form types in ActiveForm.ActiveForm::staticOnly
property.showHints
property to ActiveField configuration.Date: 04-Dec-2014
showLabels
property in ActiveForm & ActiveField to be tristate:
true
: show labelsfalse
: hide labelsActiveForm::SCREEN_READER
: show in screen reader only (hide from normal display)disabled
and readonly
properties in ActiveForm.false
to hide them completelyDate: 26-Nov-2014
Date: 17-Nov-2014
Date: 08-Nov-2014
Comments