# ActiveField

> Renders a Bootstrap 6 form field for the layouts of yii2\extensions\bootstrap6\ActiveForm.

[API reference](/docs/api/index.md) › [Bootstrap 6](/docs/extensions/bootstrap6/reference/index.md) › ActiveField

| class | `yii2\extensions\bootstrap6\ActiveField` |
| --- | --- |
| Extends | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) » [`yii\base\Component`](/docs/api/yii/base/component/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Source | [`src/ActiveField.php`](https://github.com/yii2-extensions/bootstrap6/blob/main/src/ActiveField.php#L59) |

Renders a Bootstrap 6 form field for the layouts of [`ActiveForm`](/docs/extensions/bootstrap6/reference/activeform/index.md).

Markup per layout (`{error}` is the `.invalid-feedback` element, `{hint}` the `.form-text` element):

- default: `<div class="form-field mb-3">` + label, control, hint, and error stacked by the `.form-field` grid.
- horizontal: `<div class="row mb-3">` + `<label class="sm:col-2 col-form-label">` + `<div class="sm:col-10">`
  wrapping the control, hint, and error. Checkboxes and radios render `<div class="sm:col-10 sm:offset-2">` +
  `<div class="form-field">`. Grid classes come from [`$horizontalCssClasses`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-horizontalCssClasses).
- inline: the form is a `row lg:row-cols-auto g-3 align-items-center` grid and each field is `<div class="col-12">`
  with a `visually-hidden` label, a placeholder, and no error. Checkboxes and radios render a nested
  `<div class="form-field">`.
- floating: `<div class="form-field mb-3">` + `<div class="form-floating">` holding the label BEFORE the control,
  then hint and error outside the wrapper, as in the Bootstrap validation docs. The feedback is a sibling of the
  wrapper, not of the control, so the wrapper carries the error CSS class on the server when the attribute has
  errors. On the client, a `:has()` rule registered once per form displays the sibling feedback as soon as the
  control (or the container in [`ActiveForm::VALIDATION_STATE_ON_CONTAINER`](/docs/api/yii/widgets/activeform/index.md#const-VALIDATION_STATE_ON_CONTAINER) mode) carries the error CSS class,
  so any client validation layer works without jQuery.
  The feedback is not placed inside `.form-floating` because the absolutely positioned label spans the whole
  wrapper height, so the feedback would push the floated label over the control value.

Checkboxes, radios, and switches are rendered by [`Html`](/docs/extensions/bootstrap6/reference/html/index.md) (`.check`, `.radio`, `.switch`) with a plain label; the
`.form-field` grid lays them out in two columns. Lists render one `.form-field` per item and the error after the list
container, which receives the error CSS class. Size controls with `form-control-sm` or `form-control-lg` through
[`$inputOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inputOptions) or the per-call `class` option; [`dropDownList()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-dropDownList), [`listBox()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-listBox), and [`fileInput()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-fileInput)
keep `form-control` when a per-call `class` is given.

Besides the core placeholders, [`$template`](/docs/api/yii/widgets/activefield/index.md#property-template) accepts `{beginLabel}`, `{labelTitle}`, `{endLabel}` (label parts),
and `{beginWrapper}`, `{endWrapper}` (tags built from [`$wrapperOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-wrapperOptions)).

See also: <https://getbootstrap.com/docs/6.0/forms/field/>, <https://getbootstrap.com/docs/6.0/forms/layout/>, <https://getbootstrap.com/docs/6.0/forms/floating-labels/>.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-addAriaAttributes"></span>[`$addAriaAttributes`](/docs/api/yii/widgets/activefield/index.md#property-addAriaAttributes) | `bool` | Adds aria HTML attributes `aria-required` and `aria-invalid` for inputs Default: `true`. Available since 2.0.11. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-attribute"></span>[`$attribute`](/docs/api/yii/widgets/activefield/index.md#property-attribute) | `string` | The model attribute that this field is associated with. Default: `null`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-behaviors"></span>[`$behaviors`](/docs/api/yii/base/component/index.md#property-behaviors) read-only | `array<`[`yii\base\Behavior`](/docs/api/yii/base/behavior/index.md)`<static>>` | List of behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="property-checkEnclosedTemplate"></span>`$checkEnclosedTemplate` | `string` | Template for checkboxes and radios enclosed by their label. Default: `"{beginLabel}\n{input}\n{labelTitle}\n{endLabel}\n{hint}\n{error}"`. | `ActiveField` |
| <span id="property-checkHorizontalTemplate"></span>`$checkHorizontalTemplate` | `string` | Template for checkboxes and radios in the horizontal layout. Default: `"{beginWrapper}\n<div class=\"form-field\">\n{input}\n{label}\n{hint}\n" . "{error}\n</div>\n{endWrapper}"`. | `ActiveField` |
| <span id="property-checkOptions"></span>`$checkOptions` | `mixed[]` | Default options of [`checkbox()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-checkbox) and of the [`checkboxList()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-checkboxList) items. Default: `[]`. | `ActiveField` |
| <span id="property-checkTemplate"></span>`$checkTemplate` | `string` | Template for checkboxes and radios; the inline layout wraps it in `<div class="form-field">`. Default: `"{input}\n{label}\n{hint}\n{error}"`. | `ActiveField` |
| <span id="property-enableAjaxValidation"></span>[`$enableAjaxValidation`](/docs/api/yii/widgets/activefield/index.md#property-enableAjaxValidation) | `bool\|null` | Whether to enable AJAX-based data validation. Default: `null`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-enableClientValidation"></span>[`$enableClientValidation`](/docs/api/yii/widgets/activefield/index.md#property-enableClientValidation) | `bool\|null` | Whether to enable client-side data validation. Default: `null`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-enableError"></span>`$enableError` | `bool` | Whether to render the error element; `false` by default in the inline layout. Default: `true`. | `ActiveField` |
| <span id="property-enableLabel"></span>`$enableLabel` | `bool` | Whether to render the label. Default: `true`. | `ActiveField` |
| <span id="property-errorOptions"></span>`$errorOptions` | `mixed[]` | Default: `['class' => 'invalid-feedback']`. | `ActiveField` |
| <span id="property-form"></span>[`$form`](/docs/api/yii/widgets/activefield/index.md#property-form) | [`yii\widgets\ActiveForm`](/docs/api/yii/widgets/activeform/index.md) | The form that this field is associated with. Default: `null`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-hintOptions"></span>`$hintOptions` | `mixed[]` | Default: `['class' => 'form-text']`. | `ActiveField` |
| <span id="property-horizontalCssClasses"></span>`$horizontalCssClasses` | `mixed[]` | Grid classes of the horizontal layout, keyed by `error`, `field`, `hint`, `label`, `offset` (wrapper of fields without label), and `wrapper`. Default: `[]`. | `ActiveField` |
| <span id="property-inline"></span>`$inline` | `bool` | Whether [`checkboxList()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-checkboxList) and [`radioList()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-radioList) lay out their items horizontally. Default: `false`. | `ActiveField` |
| <span id="property-inputOptions"></span>`$inputOptions` | `mixed[]` | Default: `['class' => 'form-control']`. | `ActiveField` |
| <span id="property-inputTemplate"></span>`$inputTemplate` | `string\|null` | Template wrapping the rendered control, for example an input group: `<div class="input-group">{input}</div>`. Default: `null`. | `ActiveField` |
| <span id="property-labelOptions"></span>`$labelOptions` | `mixed[]` | Default: `['class' => 'form-label']`. | `ActiveField` |
| <span id="property-model"></span>[`$model`](/docs/api/yii/widgets/activefield/index.md#property-model) | [`yii\base\Model`](/docs/api/yii/base/model/index.md) | The data model that this field is associated with. Default: `null`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-options"></span>`$options` | `mixed[]` | Default: `['class' => 'form-field mb-3']`. | `ActiveField` |
| <span id="property-parts"></span>[`$parts`](/docs/api/yii/widgets/activefield/index.md#property-parts) | `array` | Different parts of the field (e.g. input, label). Default: `[]`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-radioOptions"></span>`$radioOptions` | `mixed[]` | Default options of [`radio()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-radio) and of the [`radioList()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-radioList) items. Default: `[]`. | `ActiveField` |
| <span id="property-selectors"></span>[`$selectors`](/docs/api/yii/widgets/activefield/index.md#property-selectors) | `array` | The jQuery selectors for selecting the container, input and error tags. Default: `[]`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-template"></span>[`$template`](/docs/api/yii/widgets/activefield/index.md#property-template) | `string` | The template that is used to arrange the label, the input field, the error message and the hint text. Default: `"{label}\n{input}\n{hint}\n{error}"`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-validateOnBlur"></span>[`$validateOnBlur`](/docs/api/yii/widgets/activefield/index.md#property-validateOnBlur) | `bool\|null` | Whether to perform validation when the input field loses focus. Default: `null`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-validateOnChange"></span>[`$validateOnChange`](/docs/api/yii/widgets/activefield/index.md#property-validateOnChange) | `bool\|null` | Whether to perform validation when the value of the input field is changed. Default: `null`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-validateOnType"></span>[`$validateOnType`](/docs/api/yii/widgets/activefield/index.md#property-validateOnType) | `bool\|null` | Whether to perform validation while the user is typing in the input field. Default: `null`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-validationDelay"></span>[`$validationDelay`](/docs/api/yii/widgets/activefield/index.md#property-validationDelay) | `int\|null` | Number of milliseconds that the validation should be delayed when the user types in the field and [`$validateOnType`](/docs/api/yii/widgets/activefield/index.md#property-validateOnType) is set `true`. Default: `null`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="property-wrapperOptions"></span>`$wrapperOptions` | `mixed[]` | HTML attributes of the `{beginWrapper}` tag; the `tag` option sets the tag name (default `div`). Default: `[]`. | `ActiveField` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) |  | `ActiveField` |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/component/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__clone"></span>[`__clone()`](/docs/api/yii/base/component/index.md#method-__clone) | This method is called after the object is created by cloning an existing one. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/component/index.md#method-__get) | Returns the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/component/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/component/index.md#method-__set) | Sets the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__toString"></span>[`__toString()`](/docs/api/yii/widgets/activefield/index.md#method-__toString) | PHP magic method that returns the string representation of this object. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/component/index.md#method-__unset) | Sets a component property to be null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehavior"></span>[`attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) | Attaches a behavior to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehaviors"></span>[`attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) | Attaches a list of behaviors to the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-begin"></span>[`begin()`](/docs/api/yii/widgets/activefield/index.md#method-begin) | Renders the opening tag of the field container. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="method-behaviors"></span>[`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) | Returns a list of behaviors that this component should behave as. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/component/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/component/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`checkbox()`](#method-checkbox) | Renders a checkbox, or a switch with the `switch` option. | `ActiveField` |
| [`checkboxList()`](#method-checkboxList) | Renders a list of checkboxes, see [`Html::checkboxList()`](/docs/extensions/bootstrap6/reference/basehtml/index.md#method-checkboxList). | `ActiveField` |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| [`colorInput()`](#method-colorInput) | Renders a color picker with the `form-control form-control-color` classes. | `ActiveField` |
| <span id="method-detachBehavior"></span>[`detachBehavior()`](/docs/api/yii/base/component/index.md#method-detachBehavior) | Detaches a behavior from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-detachBehaviors"></span>[`detachBehaviors()`](/docs/api/yii/base/component/index.md#method-detachBehaviors) | Detaches all behaviors from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`dropDownList()`](#method-dropDownList) |  | `ActiveField` |
| <span id="method-end"></span>[`end()`](/docs/api/yii/widgets/activefield/index.md#method-end) | Renders the closing tag of the field container. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="method-ensureBehaviors"></span>[`ensureBehaviors()`](/docs/api/yii/base/component/index.md#method-ensureBehaviors) | Makes sure that the behaviors declared in [`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) are attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`error()`](#method-error) |  | `ActiveField` |
| [`fileInput()`](#method-fileInput) | Merges [`$inputOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inputOptions) before the core method, which skips them on Yii 2.0.x when they equal the core default `['class' => 'form-control']`. | `ActiveField` |
| <span id="method-getBehavior"></span>[`getBehavior()`](/docs/api/yii/base/component/index.md#method-getBehavior) | Returns the named behavior object. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehaviors"></span>[`getBehaviors()`](/docs/api/yii/base/component/index.md#method-getBehaviors) | Returns all behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasEventHandlers"></span>[`hasEventHandlers()`](/docs/api/yii/base/component/index.md#method-hasEventHandlers) | Returns a value indicating whether there is any handler attached to the named event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/component/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/component/index.md#method-hasProperty) | Returns a value indicating whether a property is defined for this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hiddenInput"></span>[`hiddenInput()`](/docs/api/yii/widgets/activefield/index.md#method-hiddenInput) | Renders a hidden input. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| [`hint()`](#method-hint) |  | `ActiveField` |
| <span id="method-init"></span>[`init()`](/docs/api/yii/base/baseobject/index.md#method-init) | Initializes the object. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| [`inline()`](#method-inline) | Sets whether [`checkboxList()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-checkboxList) and [`radioList()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-radioList) lay out their items horizontally. | `ActiveField` |
| [`input()`](#method-input) |  | `ActiveField` |
| [`label()`](#method-label) | Renders the label, or enables or disables it with a `bool` argument. | `ActiveField` |
| [`listBox()`](#method-listBox) |  | `ActiveField` |
| <span id="method-off"></span>[`off()`](/docs/api/yii/base/component/index.md#method-off) | Detaches an existing event handler from this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-on"></span>[`on()`](/docs/api/yii/base/component/index.md#method-on) | Attaches an event handler to an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`passwordInput()`](#method-passwordInput) |  | `ActiveField` |
| [`radio()`](#method-radio) | Renders a radio. | `ActiveField` |
| [`radioList()`](#method-radioList) | Renders a list of radios, see [`Html::radioList()`](/docs/extensions/bootstrap6/reference/basehtml/index.md#method-radioList). | `ActiveField` |
| [`rangeInput()`](#method-rangeInput) | Renders a range input wrapped in the `.form-range` element and registers the plugin bundle that initializes it. | `ActiveField` |
| [`render()`](#method-render) |  | `ActiveField` |
| [`staticControl()`](#method-staticControl) | Renders a read-only plain-text control with the attribute value. | `ActiveField` |
| [`textarea()`](#method-textarea) |  | `ActiveField` |
| [`textInput()`](#method-textInput) |  | `ActiveField` |
| <span id="method-trigger"></span>[`trigger()`](/docs/api/yii/base/component/index.md#method-trigger) | Triggers an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`widget()`](#method-widget) |  | `ActiveField` |
| <span id="method-addAriaAttributes"></span>[`addAriaAttributes()`](/docs/api/yii/widgets/activefield/index.md#method-addAriaAttributes) protected | Adds aria attributes to the input options. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="method-addErrorClassIfNeeded"></span>[`addErrorClassIfNeeded()`](/docs/api/yii/widgets/activefield/index.md#method-addErrorClassIfNeeded) protected | Adds validation class to the input options if needed. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="method-addRoleAttributes"></span>[`addRoleAttributes()`](/docs/api/yii/widgets/activefield/index.md#method-addRoleAttributes) protected | Add role attributes to the input options | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="method-adjustLabelFor"></span>[`adjustLabelFor()`](/docs/api/yii/widgets/activefield/index.md#method-adjustLabelFor) protected | Adjusts the `for` attribute for the label based on the input options. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| [`createLayoutConfig()`](#method-createLayoutConfig) protected | Returns the layout-specific default configuration. | `ActiveField` |
| <span id="method-generateLabel"></span>[`generateLabel()`](/docs/api/yii/widgets/activefield/index.md#method-generateLabel) protected | Generates the label element based on `labelOptions` configuration when `enclosedByLabel` is `false`. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="method-getClientOptions"></span>[`getClientOptions()`](/docs/api/yii/widgets/activefield/index.md#method-getClientOptions) protected | Returns the JS options for the field. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="method-getInputId"></span>[`getInputId()`](/docs/api/yii/widgets/activefield/index.md#method-getInputId) protected | Returns the HTML `id` of the input element of this form field. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| [`horizontalCssClass()`](#method-horizontalCssClass) protected | Returns a grid class of [`$horizontalCssClasses`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-horizontalCssClasses), or an empty array when it is unset or empty. | `ActiveField` |
| <span id="method-isAjaxValidationEnabled"></span>[`isAjaxValidationEnabled()`](/docs/api/yii/widgets/activefield/index.md#method-isAjaxValidationEnabled) protected | Checks if ajax validation enabled for the field. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| <span id="method-isClientValidationEnabled"></span>[`isClientValidationEnabled()`](/docs/api/yii/widgets/activefield/index.md#method-isClientValidationEnabled) protected | Checks if client validation enabled for the field. | [`yii\widgets\ActiveField`](/docs/api/yii/widgets/activefield/index.md) |
| [`layout()`](#method-layout) protected | Returns the layout of the owning form, or [`ActiveForm::LAYOUT_DEFAULT`](/docs/extensions/bootstrap6/reference/activeform/index.md#const-LAYOUT_DEFAULT) for a non-Bootstrap form. | `ActiveField` |
| [`registerFloatingFeedbackStyle()`](#method-registerFloatingFeedbackStyle) protected | Registers, once per form, the style rule that displays the feedback following a `.form-floating` wrapper when its control or its container carries the error CSS class. Whitespace-separated classes in [`ActiveForm::$errorCssClass`](/docs/extensions/bootstrap6/reference/activeform/index.md#property-errorCssClass) are matched together; no rule is registered when it holds no class. | `ActiveField` |
| [`renderBooleanInput()`](#method-renderBooleanInput) protected | Renders a checkbox or radio with the layout-specific template and label. | `ActiveField` |
| [`renderLabelParts()`](#method-renderLabelParts) protected | Renders the `{beginLabel}`, `{labelTitle}`, and `{endLabel}` parts. | `ActiveField` |
| [`renderListInput()`](#method-renderListInput) protected | Renders a checkbox or radio list with the list label pointing to no control. | `ActiveField` |
| [`renderWrapperParts()`](#method-renderWrapperParts) protected | Builds the `{beginWrapper}` and `{endWrapper}` parts unless they are already set. | `ActiveField` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(array<string, mixed> $config = [])
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$config` | `array<string, mixed>` | Configuration merged over the defaults of [`createLayoutConfig()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-createLayoutConfig). |

### checkbox() <span id="method-checkbox"></span>

```php
public function checkbox(mixed[] $options = [], bool $enclosedByLabel = false): static
```

Renders a checkbox, or a switch with the `switch` option.

Besides the options of [`Html::checkbox()`](/docs/api/yii/helpers/basehtml/index.md#method-checkbox), the following options are handled: `label` (`false` hides
it), `labelOptions`, `template`, and `wrapperOptions`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `mixed[]` | Input attributes merged over [`$checkOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-checkOptions). |
| `$enclosedByLabel` | `bool` | Whether to render the input inside the label ([`$checkEnclosedTemplate`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-checkEnclosedTemplate)). |

**Returns**

`static`

**See also**

- <https://getbootstrap.com/docs/6.0/forms/checkbox/>
- <https://getbootstrap.com/docs/6.0/forms/switch/>

### checkboxList() <span id="method-checkboxList"></span>

```php
public function checkboxList(mixed[] $items, mixed[] $options = []): static
```

Renders a list of checkboxes, see [`Html::checkboxList()`](/docs/extensions/bootstrap6/reference/basehtml/index.md#method-checkboxList).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$items` | `mixed[]` | Data items, value => label. |
| `$options` | `mixed[]` | List options; `inline` defaults to [`$inline`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inline). |

**Returns**

`static`

### colorInput() <span id="method-colorInput"></span>

```php
public function colorInput(mixed[] $options = []): static
```

Renders a color picker with the `form-control form-control-color` classes.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `mixed[]` | Input attributes. |

**Returns**

`static`

**See also**

- <https://getbootstrap.com/docs/6.0/forms/form-control/#color>

### dropDownList() <span id="method-dropDownList"></span>

```php
public function dropDownList(mixed[] $items, mixed[] $options = []): static
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$items` | `mixed[]` | Option data items. |
| `$options` | `mixed[]` | Tag attributes; a `class` keeps `form-control`, and the `placeholder` of [`$inputOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inputOptions) is not inherited. |

**Returns**

`static`

### error() <span id="method-error"></span>

```php
public function error(mixed[]|false $options = []): static
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `mixed[]\|false` | Tag attributes, or `false` to omit the error element. |

**Returns**

`static`

### fileInput() <span id="method-fileInput"></span>

```php
public function fileInput(mixed[] $options = []): static
```

Merges [`$inputOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inputOptions) before the core method, which skips them on Yii 2.0.x when they equal the core
default `['class' => 'form-control']`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `mixed[]` | Tag attributes; a `class` keeps `form-control`. |

**Returns**

`static`

### hint() <span id="method-hint"></span>

```php
public function hint(bool|string|null $content, mixed[] $options = []): static
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$content` | `bool\|string\|null` | Hint content, `null` for the model hint, or `false` to omit it. |
| `$options` | `mixed[]` | Tag attributes. |

**Returns**

`static`

### inline() <span id="method-inline"></span>

```php
public function inline(bool $value = true): static
```

Sets whether [`checkboxList()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-checkboxList) and [`radioList()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-radioList) lay out their items horizontally.

Call it before the list method.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `bool` |  |

**Returns**

`static`

### input() <span id="method-input"></span>

```php
public function input(string $type, mixed[] $options = []): static
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$type` | `string` | Input type. |
| `$options` | `mixed[]` | Tag attributes merged over [`$inputOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inputOptions). |

**Returns**

`static`

### label() <span id="method-label"></span>

```php
public function label(bool|string|null $label = null, mixed[]|null $options = []): static
```

Renders the label, or enables or disables it with a `bool` argument.

Disabling the label in the horizontal layout adds the `offset` grid class to the wrapper.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$label` | `bool\|string\|null` | Label content (not encoded), `null` for the model label, or a `bool`. |
| `$options` | `mixed[]\|null` | Tag attributes merged over [`$labelOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-labelOptions). |

**Returns**

`static`

### listBox() <span id="method-listBox"></span>

```php
public function listBox(mixed[] $items, mixed[] $options = []): static
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$items` | `mixed[]` | Option data items. |
| `$options` | `mixed[]` | Tag attributes; a `class` keeps `form-control`, and the `placeholder` of [`$inputOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inputOptions) is not inherited. |

**Returns**

`static`

### passwordInput() <span id="method-passwordInput"></span>

```php
public function passwordInput(mixed[] $options = []): static
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `mixed[]` | Tag attributes merged over [`$inputOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inputOptions). |

**Returns**

`static`

### radio() <span id="method-radio"></span>

```php
public function radio(mixed[] $options = [], bool $enclosedByLabel = false): static
```

Renders a radio.

Accepts the same options as [`checkbox()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-checkbox) except `switch`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `mixed[]` | Input attributes merged over [`$radioOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-radioOptions). |
| `$enclosedByLabel` | `bool` | Whether to render the input inside the label ([`$checkEnclosedTemplate`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-checkEnclosedTemplate)). |

**Returns**

`static`

**See also**

- <https://getbootstrap.com/docs/6.0/forms/radio/>

### radioList() <span id="method-radioList"></span>

```php
public function radioList(mixed[] $items, mixed[] $options = []): static
```

Renders a list of radios, see [`Html::radioList()`](/docs/extensions/bootstrap6/reference/basehtml/index.md#method-radioList).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$items` | `mixed[]` | Data items, value => label. |
| `$options` | `mixed[]` | List options; `inline` defaults to [`$inline`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inline). |

**Returns**

`static`

### rangeInput() <span id="method-rangeInput"></span>

```php
public function rangeInput(mixed[] $options = []): static
```

Renders a range input wrapped in the `.form-range` element and registers the plugin bundle that initializes it.

The `rangeOptions` option holds the HTML attributes of the wrapper, for example `data-bs-bubble` or a theme
class.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `mixed[]` | Input attributes, for example `min`, `max`, `step`, or `list`. |

**Returns**

`static`

**See also**

- <https://getbootstrap.com/docs/6.0/forms/range/>

### render() <span id="method-render"></span>

```php
public function render(callable(): mixed|string|null $content = null): string
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$content` | `callable(): mixed\|string\|null` | Field content, or `null` to render the parts with [`$template`](/docs/api/yii/widgets/activefield/index.md#property-template). |

**Returns**

`string`

### staticControl() <span id="method-staticControl"></span>

```php
public function staticControl(mixed[] $options = []): static
```

Renders a read-only plain-text control with the attribute value.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `mixed[]` | Tag attributes; the `value` option replaces the attribute value. |

**Returns**

`static`

**See also**

- <https://getbootstrap.com/docs/6.0/forms/form-control/#readonly-plain-text>

### textarea() <span id="method-textarea"></span>

```php
public function textarea(mixed[] $options = []): static
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `mixed[]` | Tag attributes merged over [`$inputOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inputOptions). |

**Returns**

`static`

### textInput() <span id="method-textInput"></span>

```php
public function textInput(mixed[] $options = []): static
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$options` | `mixed[]` | Tag attributes merged over [`$inputOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-inputOptions). |

**Returns**

`static`

### widget() <span id="method-widget"></span>

```php
public function widget(string $class, mixed[] $config = []): static
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$class` | `string` | Widget class name. |
| `$config` | `mixed[]` | Widget configuration. |

**Returns**

`static`

### createLayoutConfig() <span id="method-createLayoutConfig"></span>

```php
protected function createLayoutConfig(mixed[] $instanceConfig): array<string, mixed>
```

Returns the layout-specific default configuration.

Defaults are taken from the current property values, so subclasses can redefine them.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$instanceConfig` | `mixed[]` | Configuration passed to the constructor. |

**Returns**

`array<string, mixed>`: Configuration merged under the constructor configuration.

### horizontalCssClass() <span id="method-horizontalCssClass"></span>

```php
protected function horizontalCssClass(string $key): mixed[]|string
```

Returns a grid class of [`$horizontalCssClasses`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-horizontalCssClasses), or an empty array when it is unset or empty.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$key` | `string` |  |

**Returns**

`mixed[]|string`

### layout() <span id="method-layout"></span>

```php
protected function layout(): string
```

Returns the layout of the owning form, or [`ActiveForm::LAYOUT_DEFAULT`](/docs/extensions/bootstrap6/reference/activeform/index.md#const-LAYOUT_DEFAULT) for a non-Bootstrap form.

**Returns**

`string`

### registerFloatingFeedbackStyle() <span id="method-registerFloatingFeedbackStyle"></span>

```php
protected function registerFloatingFeedbackStyle(): void
```

Registers, once per form, the style rule that displays the feedback following a `.form-floating` wrapper when
its control or its container carries the error CSS class. Whitespace-separated classes in
[`ActiveForm::$errorCssClass`](/docs/extensions/bootstrap6/reference/activeform/index.md#property-errorCssClass) are matched together; no rule is registered when it holds no class.

The form `id` and each class are escaped through [`Html::escapeCssIdentifier()`](/docs/extensions/bootstrap6/reference/basehtml/index.md#method-escapeCssIdentifier); the registration key keeps
the raw `id`.

**See also**

- <https://developer.mozilla.org/en-US/docs/Web/CSS/:has>

### renderBooleanInput() <span id="method-renderBooleanInput"></span>

```php
protected function renderBooleanInput(string $type, mixed[] $options, bool $enclosedByLabel): void
```

Renders a checkbox or radio with the layout-specific template and label.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$type` | `string` | Input type, either `checkbox` or `radio`. |
| `$options` | `mixed[]` | Input attributes and the special options of [`checkbox()`](/docs/extensions/bootstrap6/reference/activefield/index.md#method-checkbox). |
| `$enclosedByLabel` | `bool` | Whether to render the input inside the label. |

### renderLabelParts() <span id="method-renderLabelParts"></span>

```php
protected function renderLabelParts(string|null $label = null, mixed[] $options = []): void
```

Renders the `{beginLabel}`, `{labelTitle}`, and `{endLabel}` parts.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$label` | `string\|null` | Label content, or `null` for the `label` option or the encoded model label. |
| `$options` | `mixed[]` | Tag attributes merged over [`$labelOptions`](/docs/extensions/bootstrap6/reference/activefield/index.md#property-labelOptions). |

### renderListInput() <span id="method-renderListInput"></span>

```php
protected function renderListInput(string $type, mixed[] $items, mixed[] $options): void
```

Renders a checkbox or radio list with the list label pointing to no control.

In the floating layout the list cannot float, so it uses the stacked template and a `.form-label` label.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$type` | `string` | Input type, either `checkbox` or `radio`. |
| `$items` | `mixed[]` | Data items, value => label. |
| `$options` | `mixed[]` | List options. |

### renderWrapperParts() <span id="method-renderWrapperParts"></span>

```php
protected function renderWrapperParts(): void
```

Builds the `{beginWrapper}` and `{endWrapper}` parts unless they are already set.

In the floating layout the wrapper receives the error CSS class, so the sibling feedback is displayed.