Class kartik\widgets\ActiveField

Inheritancekartik\widgets\ActiveField » kartik\form\ActiveField » yii\widgets\ActiveField » yii\base\Component » yii\base\BaseObject
Implementsyii\base\Configurable
Uses Traitskartik\base\AddonTrait
Available since version1.0

Extends the ActiveField component to handle various bootstrap form types and handle input groups.

Example(s): `php echo $this->form->field($model, 'email', ['addon' => ['type'=>'prepend', 'content'=>'@']]); echo $this->form->field($model, 'amount_paid', ['addon' => ['type'=>'append', 'content'=>'.00']]); echo $this->form->field($model, 'phone', ['addon' => ['type'=>'prepend', 'content'=>'<i class="glyphicon

glyphicon-phone']]);

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$addAriaAttributes boolean Adds aria HTML attributes aria-required and aria-invalid for inputs yii\widgets\ActiveField
$addClass string CSS classname to add to the input kartik\form\ActiveField
$addon array Addon to prepend or append to the widget (based on bootstrap input group styling). kartik\base\AddonTrait
$attribute string The model attribute that this field is associated with. yii\widgets\ActiveField
$autoOffset boolean Whether to auto offset toggle inputs (checkboxes / radios) horizontal form layout for BS 4. kartik\form\ActiveField
$autoPlaceholder boolean Whether the label is to be hidden and auto-displayed as a placeholder kartik\form\ActiveField
$behaviors yii\base\Behavior[] List of behaviors attached to this component. yii\base\Component
$checkEnclosedTemplate string The template for rendering checkboxes and radios for a default Bootstrap markup with an enclosed label kartik\form\ActiveField
$checkTemplate string The template for rendering checkboxes and radios for a default Bootstrap markup without an enclosed label kartik\form\ActiveField
$checkWrapperOptions array The HTML attributes for the container wrapping BS4 checkbox or radio controls within which the content will be rendered via the $checkTemplate or $checkEnclosedTemplate kartik\form\ActiveField
$contentAfterError string Content to be placed after error block kartik\form\ActiveField
$contentAfterField string Content to be placed after field within the form group at the end kartik\form\ActiveField
$contentAfterHint string Content to be placed after hint block kartik\form\ActiveField
$contentAfterInput string Content to be placed after input kartik\form\ActiveField
$contentAfterLabel string Content to be placed after label kartik\form\ActiveField
$contentBeforeError string Content to be placed before error block kartik\form\ActiveField
$contentBeforeField string Content to be placed before field within the form group at the beginning kartik\form\ActiveField
$contentBeforeHint string Content to be placed before hint block kartik\form\ActiveField
$contentBeforeInput string Content to be placed before input kartik\form\ActiveField
$contentBeforeLabel string Content to be placed before label kartik\form\ActiveField
$customFileTemplate string The template for rendering the Bootstrap 4. kartik\form\ActiveField
$deviceSize string One of the bootstrap sizes (refer the ActiveForm::SIZE constants) kartik\form\ActiveField
$enableAjaxValidation boolean|null Whether to enable AJAX-based data validation. yii\widgets\ActiveField
$enableClientValidation boolean|null Whether to enable client-side data validation. yii\widgets\ActiveField
$enableError boolean Whether to render the error. kartik\form\ActiveField
$enableLabel boolean Whether to render the label. kartik\form\ActiveField
$errorOptions array The default options for the error tags. yii\widgets\ActiveField
$feedbackIcon array The feedback icon configuration (applicable for [bootstrap text inputs](http://getbootstrap. kartik\form\ActiveField
$form kartik\widgets\ActiveForm kartik\widgets\ActiveField
$highlightAddon boolean Whether to highlight error and success states on input group addons automatically kartik\form\ActiveField
$hintOptions array The default options for the hint tags. yii\widgets\ActiveField
$hintSettings array The settings for displaying the hint. kartik\form\ActiveField
$hintType integer The hint display type. kartik\form\ActiveField
$horizontalCssClasses null|array CSS grid classes for horizontal layout. kartik\form\ActiveField
$inputOptions array The default options for the input tags. yii\widgets\ActiveField
$labelOptions array The default options for the label tags. kartik\form\ActiveField
$labelSpan integer The bootstrap grid column width (usually between 1 to 12) kartik\form\ActiveField
$model yii\base\Model The data model that this field is associated with. yii\widgets\ActiveField
$options array The HTML attributes (name-value pairs) for the field container tag. yii\widgets\ActiveField
$parts array Different parts of the field (e.g. input, label). yii\widgets\ActiveField
$renderEmptyWrapper boolean Whether to render the wrapper in the template if $wrapperOptions is empty. kartik\form\ActiveField
$selectors array The jQuery selectors for selecting the container, input and error tags. yii\widgets\ActiveField
$showErrors boolean Whether to show errors for the field kartik\form\ActiveField
$showHints boolean Whether to show hints for the field kartik\form\ActiveField
$showLabels boolean|string Whether to show labels for the field. kartik\form\ActiveField
$showRequiredIndicator boolean Whether to show required asterisk/star indicator after each field label when the model attribute is set to have a required validation rule. kartik\form\ActiveField
$skipFormLayout boolean Whether to override the form layout styles and skip field formatting as per the form layout. kartik\form\ActiveField
$staticValue string The static value for the field to be displayed for the static input OR when the form is in staticOnly mode. kartik\form\ActiveField
$template string Inherits and overrides values from parent class. kartik\form\ActiveField
$validateOnBlur boolean|null Whether to perform validation when the input field loses focus. yii\widgets\ActiveField
$validateOnChange boolean|null Whether to perform validation when the value of the input field is changed. yii\widgets\ActiveField
$validateOnType boolean|null Whether to perform validation while the user is typing in the input field. yii\widgets\ActiveField
$validationDelay integer|null Number of milliseconds that the validation should be delayed when the user types in the field and $validateOnType is set true. yii\widgets\ActiveField
$wrapperOptions array Options for the wrapper tag, used in the {beginWrapper} token within $template. kartik\form\ActiveField

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$_hasFeedback boolean Whether there is a feedback icon configuration set kartik\form\ActiveField
$_isHintSpecial boolean Whether there is a feedback icon configuration set kartik\form\ActiveField
$_isStatic boolean Is it a static input kartik\form\ActiveField
$_multiselect boolean The container for multi select kartik\form\ActiveField
$_offset boolean Whether the input is to be offset (like for checkbox or radio). kartik\form\ActiveField
$_pluginHintKeys array The list of hint keys that will be used by ActiveFieldHint jQuery plugin kartik\form\ActiveField
$_settings array The settings for the active field layout kartik\form\ActiveField

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Component
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Constructor. kartik\form\ActiveField
__get() Returns the value of a component property. yii\base\Component
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Component
__set() Sets the value of a component property. yii\base\Component
__toString() PHP magic method that returns the string representation of this object. yii\widgets\ActiveField
__unset() Sets a component property to be null. yii\base\Component
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
begin() Renders the opening tag of the field container. kartik\form\ActiveField
behaviors() Returns a list of behaviors that this component should behave as. yii\base\Component
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Component
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Component
checkbox() Renders a checkbox. This method will generate the "checked" tag attribute according to the model attribute value. kartik\form\ActiveField
checkboxButtonGroup() Renders a list of checkbox toggle buttons. kartik\form\ActiveField
checkboxList() Renders a list of checkboxes. A checkbox list allows multiple selection, like listBox(). As a result, the corresponding submitted value is an array. The selection of the checkbox list is taken from the value of the model attribute. kartik\form\ActiveField
className() Returns the fully qualified name of this class. yii\base\BaseObject
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
end() Renders the closing tag of the field container. kartik\form\ActiveField
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
error() Generates a tag that contains the first validation error of $attribute. yii\widgets\ActiveField
fileInput() Renders a file input. kartik\form\ActiveField
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event. yii\base\Component
hasMethod() Returns a value indicating whether a method is defined. yii\base\Component
hasProperty() Returns a value indicating whether a property is defined for this component. yii\base\Component
hiddenInput() Renders a hidden input. yii\widgets\ActiveField
hint() Renders the hint tag. kartik\form\ActiveField
init() Initializes the object. kartik\form\ActiveField
input() Renders an input tag. kartik\form\ActiveField
label() Generates a label tag for $attribute. kartik\form\ActiveField
listBox() Renders a list box. kartik\form\ActiveField
multiselect() Renders a multi select list box. This control extends the checkboxList and radioList available in yii\widgets\ActiveField - to display a scrolling multi select list box. kartik\form\ActiveField
off() Detaches an existing event handler from this component. yii\base\Component
on() Attaches an event handler to an event. yii\base\Component
passwordInput() Renders a password input. kartik\form\ActiveField
radio() Renders a radio button. This method will generate the "checked" tag attribute according to the model attribute value. kartik\form\ActiveField
radioButtonGroup() Renders a list of radio toggle buttons. kartik\form\ActiveField
radioList() Renders a list of radio buttons. A radio button list is like a checkbox list, except that it only allows single selection. The selection of the radio buttons is taken from the value of the model attribute. kartik\form\ActiveField
render() Renders the whole field. kartik\form\ActiveField
staticInput() Renders a static input (display only). kartik\form\ActiveField
textInput() Renders a text input. kartik\form\ActiveField
textarea() Renders a text area. kartik\form\ActiveField
trigger() Triggers an event. yii\base\Component
widget() Renders a widget as the input of the field. kartik\form\ActiveField

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
addAriaAttributes() Adds aria attributes to the input options. yii\widgets\ActiveField
addErrorClassBS4() Adds Bootstrap 4 validation class to the input options if needed. kartik\form\ActiveField
addErrorClassIfNeeded() Adds validation class to the input options if needed. yii\widgets\ActiveField
addRoleAttributes() Add role attributes to the input options yii\widgets\ActiveField
adjustLabelFor() Adjusts the for attribute for the label based on the input options. yii\widgets\ActiveField
buildLayoutParts() Builds the field layout parts kartik\form\ActiveField
buildTemplate() Builds the final template based on the bootstrap form type, display settings for label, error, and hint, and content before and after label, input, error, and hint. kartik\form\ActiveField
createLayoutConfig() Create layout specific configuration kartik\form\ActiveField
generateAddon() Generates the addon markup kartik\form\ActiveField
generateHint() Generates the hint. kartik\form\ActiveField
getAddonContent() Parses and returns addon content. kartik\base\AddonTrait
getClientOptions() Returns the JS options for the field. yii\widgets\ActiveField
getColCss() Gets bootstrap grid column CSS based on size kartik\form\ActiveField
getConfigParam() Gets configuration parameter from formConfig kartik\form\ActiveField
getCustomCss() Gets custom CSS for custom controls supported in bootstrap 4.x and 5.x kartik\form\ActiveField
getFeedbackIcon() Generates a feedback icon kartik\form\ActiveField
getHintData() Gets a hint configuration setting value kartik\form\ActiveField
getHintIcon() Generates the hint icon kartik\form\ActiveField
getHintIconCss() Gets the hint icon css based on hintSettings kartik\form\ActiveField
getInputId() Returns the HTML id of the input element of this form field. yii\widgets\ActiveField
getToggleField() Generates a toggle field (checkbox or radio) kartik\form\ActiveField
getToggleFieldList() Renders a list of checkboxes / radio buttons. The selection of the checkbox / radio buttons is taken from the value of the model attribute. kartik\form\ActiveField
hasLabels() Validate label display status kartik\form\ActiveField
initActiveField() Initialize the active field kartik\form\ActiveField
initDisability() Validates and sets disabled or readonly inputs kartik\form\ActiveField
initFieldOptions() Initializes sizes and placeholder based on $autoPlaceholder kartik\form\ActiveField
initFieldSize() Initializes field by detecting the bootstrap CSS size and sets a size modifier CSS to the field container kartik\form\ActiveField
initHints() Initialize hint settings kartik\form\ActiveField
initHorizontal() Prepares bootstrap grid col classes for horizontal layout including label and input tags and initiate private CSS variables. The process order for 'labelSpan' and 'wrapper' is as follows: kartik\form\ActiveField
initLabels() Initialize label options kartik\form\ActiveField
initLayout() Initialize layout settings for label, input, error and hint blocks and for various bootstrap 3 form layouts kartik\form\ActiveField
isAjaxValidationEnabled() Checks if ajax validation enabled for the field. yii\widgets\ActiveField
isClientValidationEnabled() Checks if client validation enabled for the field. yii\widgets\ActiveField
isCustomControl() Checks whether bootstrap 4.x custom control based on options parameter kartik\form\ActiveField
mergeSettings() Merges the parameters for layout settings kartik\form\ActiveField
renderAddonItem() Renders an addon item based on its configuration kartik\base\AddonTrait
renderFeedbackIcon() Render the bootstrap feedback icon kartik\form\ActiveField
renderLabelParts() Render the label parts kartik\form\ActiveField
setHintData() Sets a hint property setting as a data attribute within self::$options kartik\form\ActiveField
setLayoutContainer() Sets the layout element container kartik\form\ActiveField

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
HINT_DEFAULT 1 kartik\form\ActiveField
HINT_SPECIAL 2 kartik\form\ActiveField
MULTI_SELECT_HEIGHT '145px' kartik\form\ActiveField
NOT_SET '' kartik\form\ActiveField
TYPE_CHECKBOX 'checkbox' kartik\form\ActiveField
TYPE_RADIO 'radio' kartik\form\ActiveField

Property Details

$form public property