0 follower

Final Class Yiisoft\Form\Field\CheckboxList

InheritanceYiisoft\Form\Field\CheckboxList » Yiisoft\Form\Field\Base\PartsField » Yiisoft\Form\Field\Base\BaseField » Yiisoft\Widget\Widget
ImplementsYiisoft\Form\Field\Base\ValidationClass\ValidationClassInterface
Uses TraitsYiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait, Yiisoft\Form\Field\Base\ValidationClass\ValidationClassTrait

Represents a list of checkboxes with multiple selection.

See also \Yiisoft\Html\Widget\CheckboxList\CheckboxList.

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Form\Field\CheckboxList
addCheckboxAttributes() Yiisoft\Form\Field\CheckboxList
addCheckboxLabelAttributes() Yiisoft\Form\Field\CheckboxList
addCheckboxWrapClass() Yiisoft\Form\Field\CheckboxList
addContainerAttributes() Yiisoft\Form\Field\Base\BaseField
addContainerClass() Add one or more CSS classes to the container tag. Yiisoft\Form\Field\Base\BaseField
addErrorAttributes() Yiisoft\Form\Field\Base\PartsField
addErrorClass() Add one or more CSS classes to the error tag. Yiisoft\Form\Field\Base\PartsField
addHintAttributes() Yiisoft\Form\Field\Base\PartsField
addHintClass() Add one or more CSS classes to the hint tag. Yiisoft\Form\Field\Base\PartsField
addIndividualInputAttributes() Yiisoft\Form\Field\CheckboxList
addInputContainerAttributes() Yiisoft\Form\Field\Base\PartsField
addInputContainerClass() Add one or more CSS classes to the input container tag. Yiisoft\Form\Field\Base\PartsField
addLabelAttributes() Yiisoft\Form\Field\Base\PartsField
addLabelClass() Add one or more CSS classes to the label tag. Yiisoft\Form\Field\Base\PartsField
afterInput() Yiisoft\Form\Field\Base\PartsField
beforeInput() Yiisoft\Form\Field\Base\PartsField
begin() Yiisoft\Form\Field\Base\BaseField
checkboxAttributes() Yiisoft\Form\Field\CheckboxList
checkboxLabelAttributes() Yiisoft\Form\Field\CheckboxList
checkboxLabelWrap() Yiisoft\Form\Field\CheckboxList
checkboxWrapAttributes() Yiisoft\Form\Field\CheckboxList
checkboxWrapClass() Yiisoft\Form\Field\CheckboxList
checkboxWrapTag() Yiisoft\Form\Field\CheckboxList
containerAttributes() Yiisoft\Form\Field\Base\BaseField
containerClass() Replace container tag CSS classes with a new set of classes. Yiisoft\Form\Field\Base\BaseField
containerId() Set container tag ID. Yiisoft\Form\Field\Base\BaseField
containerTag() Yiisoft\Form\Field\Base\BaseField
disabled() Yiisoft\Form\Field\CheckboxList
error() Yiisoft\Form\Field\Base\PartsField
errorAttributes() Yiisoft\Form\Field\Base\PartsField
errorClass() Replace error tag CSS classes with a new set of classes. Yiisoft\Form\Field\Base\PartsField
errorConfig() Yiisoft\Form\Field\Base\PartsField
errorId() Set error tag ID. Yiisoft\Form\Field\Base\PartsField
form() Specifies the form element the tag input element belongs to. The value of this attribute must be the ID attribute of a form element in the same document. Yiisoft\Form\Field\CheckboxList
hideLabel() Yiisoft\Form\Field\Base\PartsField
hint() Yiisoft\Form\Field\Base\PartsField
hintAttributes() Yiisoft\Form\Field\Base\PartsField
hintClass() Replace hint tag CSS classes with a new set of classes. Yiisoft\Form\Field\Base\PartsField
hintConfig() Yiisoft\Form\Field\Base\PartsField
hintId() Set hint tag ID. Yiisoft\Form\Field\Base\PartsField
individualInputAttributes() Yiisoft\Form\Field\CheckboxList
inputContainerAttributes() Yiisoft\Form\Field\Base\PartsField
inputContainerClass() Replace input container tag CSS classes with a new set of classes. Yiisoft\Form\Field\Base\PartsField
inputContainerTag() Yiisoft\Form\Field\Base\PartsField
inputData() Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait
inputInvalidClass() Set invalid CSS class for input tag. Yiisoft\Form\Field\Base\ValidationClass\ValidationClassTrait
inputValidClass() Set valid CSS class for input tag. Yiisoft\Form\Field\Base\ValidationClass\ValidationClassTrait
invalidClass() Set invalid CSS class. Yiisoft\Form\Field\Base\ValidationClass\ValidationClassTrait
itemFormatter() Yiisoft\Form\Field\CheckboxList
items() Yiisoft\Form\Field\CheckboxList
itemsFromValues() Fills items from an array provided. Array values are used for both input labels and input values. Yiisoft\Form\Field\CheckboxList
label() Yiisoft\Form\Field\Base\PartsField
labelAttributes() Yiisoft\Form\Field\Base\PartsField
labelClass() Replace label tag CSS classes with a new set of classes. Yiisoft\Form\Field\Base\PartsField
labelConfig() Yiisoft\Form\Field\Base\PartsField
labelId() Set label tag ID. Yiisoft\Form\Field\Base\PartsField
name() Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait
prepareValue() Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait
render() Yiisoft\Form\Field\Base\BaseField
separator() Yiisoft\Form\Field\CheckboxList
template() Set layout template for render a field. Yiisoft\Form\Field\Base\PartsField
templateBegin() Yiisoft\Form\Field\Base\PartsField
templateEnd() Yiisoft\Form\Field\Base\PartsField
token() Yiisoft\Form\Field\Base\PartsField
tokens() Yiisoft\Form\Field\Base\PartsField
uncheckValue() Yiisoft\Form\Field\CheckboxList
useContainer() Yiisoft\Form\Field\Base\BaseField
validClass() Set valid CSS class. Yiisoft\Form\Field\Base\ValidationClass\ValidationClassTrait
value() Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait

Constants

Hide inherited constants

Constant Value Description Defined By
BUILTIN_TOKENS [ '{input}', '{label}', '{hint}', '{error}', ] Yiisoft\Form\Field\Base\PartsField

Method Details

Hide inherited methods

__construct() public method

public __construct( ): mixed

                public function __construct()
{
    $this->widget = CheckboxListWidget::create('');
}

            
addCheckboxAttributes() public method

public addCheckboxAttributes( array $attributes ): self
$attributes array

                public function addCheckboxAttributes(array $attributes): self
{
    $new = clone $this;
    $new->checkboxAttributes = array_merge($new->checkboxAttributes, $attributes);
    return $new;
}

            
addCheckboxLabelAttributes() public method

public addCheckboxLabelAttributes( array $attributes ): self
$attributes array

                public function addCheckboxLabelAttributes(array $attributes): self
{
    $new = clone $this;
    $new->widget = $this->widget->addCheckboxLabelAttributes($attributes);
    return $new;
}

            
addCheckboxWrapClass() public method

public addCheckboxWrapClass( string|null $class ): self
$class string|null

                public function addCheckboxWrapClass(?string ...$class): self
{
    $new = clone $this;
    $new->widget = $this->widget->addCheckboxWrapClass(...$class);
    return $new;
}

            
addContainerAttributes() public method
public addContainerAttributes( array $attributes ): Yiisoft\Form\Field\CheckboxList
$attributes array

                final public function addContainerAttributes(array $attributes): static
{
    $new = clone $this;
    $new->containerAttributes = array_merge($new->containerAttributes, $attributes);
    return $new;
}

            
addContainerClass() public method

Defined in: Yiisoft\Form\Field\Base\BaseField::addContainerClass()

Add one or more CSS classes to the container tag.

public addContainerClass( string|null $class ): Yiisoft\Form\Field\CheckboxList
$class string|null

One or many CSS classes.

                final public function addContainerClass(?string ...$class): static
{
    $new = clone $this;
    Html::addCssClass($new->containerAttributes, $class);
    return $new;
}

            
addErrorAttributes() public method
public addErrorAttributes( array $attributes ): Yiisoft\Form\Field\CheckboxList
$attributes array

                final public function addErrorAttributes(array $attributes): static
{
    $new = clone $this;
    $new->errorAttributes = array_merge($new->errorAttributes, $attributes);
    return $new;
}

            
addErrorClass() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::addErrorClass()

Add one or more CSS classes to the error tag.

public addErrorClass( string|null $class ): Yiisoft\Form\Field\CheckboxList
$class string|null

One or many CSS classes.

                final public function addErrorClass(?string ...$class): static
{
    $new = clone $this;
    Html::addCssClass($new->errorAttributes, $class);
    return $new;
}

            
addHintAttributes() public method
public addHintAttributes( array $attributes ): Yiisoft\Form\Field\CheckboxList
$attributes array

                final public function addHintAttributes(array $attributes): static
{
    $new = clone $this;
    $new->hintAttributes = array_merge($new->hintAttributes, $attributes);
    return $new;
}

            
addHintClass() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::addHintClass()

Add one or more CSS classes to the hint tag.

public addHintClass( string|null $class ): Yiisoft\Form\Field\CheckboxList
$class string|null

One or many CSS classes.

                final public function addHintClass(?string ...$class): static
{
    $new = clone $this;
    Html::addCssClass($new->hintAttributes, $class);
    return $new;
}

            
addIndividualInputAttributes() public method

public addIndividualInputAttributes( array[] $attributes ): self
$attributes array[]

                public function addIndividualInputAttributes(array $attributes): self
{
    $new = clone $this;
    $new->widget = $this->widget->addIndividualInputAttributes($attributes);
    return $new;
}

            
addInputContainerAttributes() public method
public addInputContainerAttributes( array $attributes ): Yiisoft\Form\Field\CheckboxList
$attributes array

                final public function addInputContainerAttributes(array $attributes): static
{
    $new = clone $this;
    $new->inputContainerAttributes = array_merge($new->inputContainerAttributes, $attributes);
    return $new;
}

            
addInputContainerClass() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::addInputContainerClass()

Add one or more CSS classes to the input container tag.

public addInputContainerClass( string|null $class ): Yiisoft\Form\Field\CheckboxList
$class string|null

One or many CSS classes.

                final public function addInputContainerClass(?string ...$class): static
{
    $new = clone $this;
    Html::addCssClass($new->inputContainerAttributes, $class);
    return $new;
}

            
addInputValidationClassToAttributes() protected method
protected addInputValidationClassToAttributes( array &$attributes, Yiisoft\Form\Field\Base\InputData\InputDataInterface $inputData, boolean|null $hasCustomError null ): void
$attributes array
$inputData Yiisoft\Form\Field\Base\InputData\InputDataInterface
$hasCustomError boolean|null

                protected function addInputValidationClassToAttributes(
    array &$attributes,
    InputDataInterface $inputData,
    ?bool $hasCustomError = null,
): void {
    $this->addClassesToAttributes(
        $attributes,
        $inputData,
        $hasCustomError,
        $this->inputInvalidClass,
        $this->inputValidClass,
    );
}

            
addLabelAttributes() public method
public addLabelAttributes( array $attributes ): Yiisoft\Form\Field\CheckboxList
$attributes array

                final public function addLabelAttributes(array $attributes): static
{
    $new = clone $this;
    $new->labelAttributes = array_merge($new->labelAttributes, $attributes);
    return $new;
}

            
addLabelClass() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::addLabelClass()

Add one or more CSS classes to the label tag.

public addLabelClass( string|null $class ): Yiisoft\Form\Field\CheckboxList
$class string|null

One or many CSS classes.

                final public function addLabelClass(?string ...$class): static
{
    $new = clone $this;
    Html::addCssClass($new->labelAttributes, $class);
    return $new;
}

            
addValidationClassToAttributes() protected method
protected addValidationClassToAttributes( array &$attributes, Yiisoft\Form\Field\Base\InputData\InputDataInterface $inputData, boolean|null $hasCustomError null ): void
$attributes array
$inputData Yiisoft\Form\Field\Base\InputData\InputDataInterface
$hasCustomError boolean|null

                protected function addValidationClassToAttributes(
    array &$attributes,
    InputDataInterface $inputData,
    ?bool $hasCustomError = null,
): void {
    $this->addClassesToAttributes(
        $attributes,
        $inputData,
        $hasCustomError,
        $this->invalidClass,
        $this->validClass,
    );
}

            
afterInput() public method
public afterInput( string|\Stringable $content ): Yiisoft\Form\Field\CheckboxList
$content string|\Stringable

                final public function afterInput(string|Stringable $content): static
{
    $new = clone $this;
    $new->afterInput = $content;
    return $new;
}

            
beforeInput() public method
public beforeInput( string|\Stringable $content ): Yiisoft\Form\Field\CheckboxList
$content string|\Stringable

                final public function beforeInput(string|Stringable $content): static
{
    $new = clone $this;
    $new->beforeInput = $content;
    return $new;
}

            
beforeRender() protected method
protected beforeRender( ): void

                protected function beforeRender(): void {}

            
begin() public method
public begin( ): string|null

                final public function begin(): ?string
{
    parent::begin();
    $this->isStartedByBegin = true;
    $this->beforeRender();
    $content = $this->generateBeginContent();
    return $this->renderOpenContainerAndContent($content);
}

            
checkboxAttributes() public method

public checkboxAttributes( array $attributes ): self
$attributes array

                public function checkboxAttributes(array $attributes): self
{
    $new = clone $this;
    $new->checkboxAttributes = $attributes;
    return $new;
}

            
checkboxLabelAttributes() public method

public checkboxLabelAttributes( array $attributes ): self
$attributes array

                public function checkboxLabelAttributes(array $attributes): self
{
    $new = clone $this;
    $new->widget = $this->widget->checkboxLabelAttributes($attributes);
    return $new;
}

            
checkboxLabelWrap() public method

public checkboxLabelWrap( boolean $wrap ): self
$wrap boolean

                public function checkboxLabelWrap(bool $wrap): self
{
    $new = clone $this;
    $new->widget = $this->widget->checkboxLabelWrap($wrap);
    return $new;
}

            
checkboxWrapAttributes() public method

public checkboxWrapAttributes( array $attributes ): self
$attributes array

                public function checkboxWrapAttributes(array $attributes): self
{
    $new = clone $this;
    $new->widget = $this->widget->checkboxWrapAttributes($attributes);
    return $new;
}

            
checkboxWrapClass() public method

public checkboxWrapClass( string|null $class ): self
$class string|null

                public function checkboxWrapClass(?string ...$class): self
{
    $new = clone $this;
    $new->widget = $this->widget->checkboxWrapClass(...$class);
    return $new;
}

            
checkboxWrapTag() public method

public checkboxWrapTag( string|null $name ): self
$name string|null

                public function checkboxWrapTag(?string $name): self
{
    $new = clone $this;
    $new->widget = $this->widget->checkboxWrapTag($name);
    return $new;
}

            
containerAttributes() public method
public containerAttributes( array $attributes ): Yiisoft\Form\Field\CheckboxList
$attributes array

                final public function containerAttributes(array $attributes): static
{
    $new = clone $this;
    $new->containerAttributes = $attributes;
    return $new;
}

            
containerClass() public method

Defined in: Yiisoft\Form\Field\Base\BaseField::containerClass()

Replace container tag CSS classes with a new set of classes.

public containerClass( string|null $class ): Yiisoft\Form\Field\CheckboxList
$class string|null

One or many CSS classes.

                final public function containerClass(?string ...$class): static
{
    $new = clone $this;
    $new->containerAttributes['class'] = array_filter($class, static fn($c) => $c !== null);
    return $new;
}

            
containerId() public method

Defined in: Yiisoft\Form\Field\Base\BaseField::containerId()

Set container tag ID.

public containerId( string|null $id ): Yiisoft\Form\Field\CheckboxList
$id string|null

Container tag ID.

                final public function containerId(?string $id): static
{
    $new = clone $this;
    $new->containerAttributes['id'] = $id;
    return $new;
}

            
containerTag() public method
public containerTag( string $tag ): Yiisoft\Form\Field\CheckboxList
$tag string

                final public function containerTag(string $tag): static
{
    if ($tag === '') {
        throw new InvalidArgumentException('Tag name cannot be empty.');
    }
    $new = clone $this;
    $new->containerTag = $tag;
    return $new;
}

            
disabled() public method

public disabled( boolean $disabled true ): self
$disabled boolean

Whether checkboxes is disabled.

                public function disabled(bool $disabled = true): self
{
    $new = clone $this;
    $new->widget = $this->widget->disabled($disabled);
    return $new;
}

            
error() public method
public error( string|null $message, string $messages ): Yiisoft\Form\Field\CheckboxList
$message string|null
$messages string

                final public function error(?string $message, string ...$messages): static
{
    $new = clone $this;
    $new->errorConfig['message()'] = [$message, ...$messages];
    return $new;
}

            
errorAttributes() public method
public errorAttributes( array $attributes ): Yiisoft\Form\Field\CheckboxList
$attributes array

                final public function errorAttributes(array $attributes): static
{
    $new = clone $this;
    $new->errorAttributes = $attributes;
    $new->replaceErrorAttributes = true;
    return $new;
}

            
errorClass() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::errorClass()

Replace error tag CSS classes with a new set of classes.

public errorClass( string|null $class ): Yiisoft\Form\Field\CheckboxList
$class string|null

One or many CSS classes.

                final public function errorClass(?string ...$class): static
{
    $new = clone $this;
    $new->errorAttributes['class'] = $class;
    $new->replaceErrorClass = true;
    return $new;
}

            
errorConfig() public method
public errorConfig( array $config ): Yiisoft\Form\Field\CheckboxList
$config array

                final public function errorConfig(array $config): static
{
    $new = clone $this;
    $new->errorConfig = $config;
    return $new;
}

            
errorId() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::errorId()

Set error tag ID.

public errorId( string|null $id ): Yiisoft\Form\Field\CheckboxList
$id string|null

Error tag ID.

                final public function errorId(?string $id): static
{
    $new = clone $this;
    $new->errorAttributes['id'] = $id;
    return $new;
}

            
form() public method

Specifies the form element the tag input element belongs to. The value of this attribute must be the ID attribute of a form element in the same document.

public form( string|null $formId ): self
$formId string|null

                public function form(?string $formId): self
{
    $new = clone $this;
    $new->widget = $this->widget->form($formId);
    return $new;
}

            
generateBeginContent() protected method
protected generateBeginContent( ): string

                final protected function generateBeginContent(): string
{
    $parts = [
        '{input}' => $this->generateBeginInput(),
        '{label}' => ($this->hideLabel ?? $this->shouldHideLabel()) ? '' : $this->generateLabel(),
        '{hint}' => $this->generateHint(),
        '{error}' => $this->generateError(),
    ];
    return $this->makeContent($this->templateBegin, $parts);
}

            
generateBeginInput() protected method
protected generateBeginInput( ): string

                protected function generateBeginInput(): string
{
    return '';
}

            
generateContent() protected method
protected generateContent( ): string|null

                final protected function generateContent(): ?string
{
    $parts = [
        '{input}' => $this->generateInputContainerBegin()
            . $this->beforeInput
            . $this->generateInput()
            . $this->afterInput
            . $this->generateInputContainerEnd(),
        '{label}' => ($this->hideLabel ?? $this->shouldHideLabel()) ? '' : $this->generateLabel(),
        '{hint}' => $this->generateHint(),
        '{error}' => $this->generateError(),
    ];
    return $this->makeContent($this->template, $parts);
}

            
generateEndContent() protected method
protected generateEndContent( ): string

                final protected function generateEndContent(): string
{
    $parts = [
        '{input}' => $this->generateEndInput(),
        '{label}' => ($this->hideLabel ?? $this->shouldHideLabel()) ? '' : $this->generateLabel(),
        '{hint}' => $this->generateHint(),
        '{error}' => $this->generateError(),
    ];
    return $this->makeContent($this->templateEnd, $parts);
}

            
generateEndInput() protected method
protected generateEndInput( ): string

                protected function generateEndInput(): string
{
    return '';
}

            
generateInput() protected method

protected generateInput( ): string

                protected function generateInput(): string
{
    $name = $this->getName();
    if (empty($name)) {
        throw new LogicException('"CheckboxList" field requires non-empty name.');
    }
    $value = $this->getValue();
    $value ??= [];
    if (!is_iterable($value)) {
        throw new InvalidArgumentException(
            '"CheckboxList" field requires iterable or null value.',
        );
    }
    /** @psalm-var iterable<int, Stringable|scalar> $value */
    $checkboxAttributes = $this->checkboxAttributes;
    $this->addInputValidationClassToAttributes(
        $checkboxAttributes,
        $this->getInputData(),
        $this->hasCustomError() ? true : null,
    );
    return $this->widget
        ->name($name)
        ->values($value)
        ->addCheckboxAttributes($checkboxAttributes)
        ->render();
}

            
getInputData() protected method
protected getInputData( ): Yiisoft\Form\Field\Base\InputData\InputDataInterface

                final protected function getInputData(): InputDataInterface
{
    if ($this->inputData === null) {
        $this->inputData = new InputData();
    }
    return $this->inputData;
}

            
getName() protected method
protected getName( ): string|null

                final protected function getName(): ?string
{
    return $this->useCustomName
        ? $this->customName
        : $this->getInputData()->getName();
}

            
getThemeConfig() protected static method
protected static getThemeConfig( string|null $theme ): array
$theme string|null

                final protected static function getThemeConfig(?string $theme): array
{
    return ThemeContainer::getTheme($theme)?->getFieldConfig(static::class) ?? [];
}

            
getValue() protected method
protected getValue( ): mixed

                final protected function getValue(): mixed
{
    $value = $this->useCustomValue
        ? $this->customValue
        : $this->getInputData()->getValue();
    return $this->prepareValueCallback === null
        ? $value
        : ($this->prepareValueCallback)($value);
}

            
hasCustomError() protected method
protected hasCustomError( ): boolean

                final protected function hasCustomError(): bool
{
    return isset($this->errorConfig['message()']);
}

            
hideLabel() public method
public hideLabel( boolean|null $hide true ): Yiisoft\Form\Field\CheckboxList
$hide boolean|null

                final public function hideLabel(?bool $hide = true): static
{
    $new = clone $this;
    $new->hideLabel = $hide;
    return $new;
}

            
hint() public method
public hint( string|null $content ): Yiisoft\Form\Field\CheckboxList
$content string|null

                final public function hint(?string $content): static
{
    $new = clone $this;
    $new->hintConfig['content()'] = [$content];
    return $new;
}

            
hintAttributes() public method
public hintAttributes( array $attributes ): Yiisoft\Form\Field\CheckboxList
$attributes array

                final public function hintAttributes(array $attributes): static
{
    $new = clone $this;
    $new->hintAttributes = $attributes;
    $new->replaceHintAttributes = true;
    return $new;
}

            
hintClass() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::hintClass()

Replace hint tag CSS classes with a new set of classes.

public hintClass( string|null $class ): Yiisoft\Form\Field\CheckboxList
$class string|null

One or many CSS classes.

                final public function hintClass(?string ...$class): static
{
    $new = clone $this;
    $new->hintAttributes['class'] = $class;
    $new->replaceHintClass = true;
    return $new;
}

            
hintConfig() public method
public hintConfig( array $config ): Yiisoft\Form\Field\CheckboxList
$config array

                final public function hintConfig(array $config): static
{
    $new = clone $this;
    $new->hintConfig = $config;
    return $new;
}

            
hintId() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::hintId()

Set hint tag ID.

public hintId( string|null $id ): Yiisoft\Form\Field\CheckboxList
$id string|null

Hint tag ID.

                final public function hintId(?string $id): static
{
    $new = clone $this;
    $new->hintAttributes['id'] = $id;
    return $new;
}

            
individualInputAttributes() public method

public individualInputAttributes( array[] $attributes ): self
$attributes array[]

                public function individualInputAttributes(array $attributes): self
{
    $new = clone $this;
    $new->widget = $this->widget->individualInputAttributes($attributes);
    return $new;
}

            
inputContainerAttributes() public method
public inputContainerAttributes( array $attributes ): Yiisoft\Form\Field\CheckboxList
$attributes array

                final public function inputContainerAttributes(array $attributes): static
{
    $new = clone $this;
    $new->inputContainerAttributes = $attributes;
    return $new;
}

            
inputContainerClass() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::inputContainerClass()

Replace input container tag CSS classes with a new set of classes.

public inputContainerClass( string|null $class ): Yiisoft\Form\Field\CheckboxList
$class string|null

One or many CSS classes.

                final public function inputContainerClass(?string ...$class): static
{
    $new = clone $this;
    $new->inputContainerAttributes['class'] = array_filter($class, static fn($c) => $c !== null);
    return $new;
}

            
inputContainerTag() public method
public inputContainerTag( string|null $tag ): Yiisoft\Form\Field\CheckboxList
$tag string|null

                final public function inputContainerTag(?string $tag): static
{
    if ($tag === '') {
        throw new InvalidArgumentException('Tag name cannot be empty.');
    }
    $new = clone $this;
    $new->inputContainerTag = $tag;
    return $new;
}

            
inputData() public method
public inputData( Yiisoft\Form\Field\Base\InputData\InputDataInterface $inputData ): Yiisoft\Form\Field\CheckboxList
$inputData Yiisoft\Form\Field\Base\InputData\InputDataInterface

                final public function inputData(InputDataInterface $inputData): static
{
    $new = clone $this;
    $new->inputData = $inputData;
    $new->useCustomName = false;
    $new->useCustomValue = false;
    return $new;
}

            
inputInvalidClass() public method
public inputInvalidClass( string|null $class ): self
$class string|null

                public function inputInvalidClass(?string $class): self
{
    $new = clone $this;
    $new->inputInvalidClass = $class;
    return $new;
}

            
inputValidClass() public method
public inputValidClass( string|null $class ): self
$class string|null

                public function inputValidClass(?string $class): self
{
    $new = clone $this;
    $new->inputValidClass = $class;
    return $new;
}

            
invalidClass() public method
public invalidClass( string|null $class ): self
$class string|null

                public function invalidClass(?string $class): self
{
    $new = clone $this;
    $new->invalidClass = $class;
    return $new;
}

            
itemFormatter() public method

public itemFormatter( Closure|null $formatter ): self
$formatter Closure|null

                public function itemFormatter(?Closure $formatter): self
{
    $new = clone $this;
    $new->widget = $this->widget->itemFormatter($formatter);
    return $new;
}

            
items() public method

public items( string[] $items, boolean $encodeLabels true ): self
$items string[]
$encodeLabels boolean

Whether labels should be encoded.

                public function items(array $items, bool $encodeLabels = true): self
{
    $new = clone $this;
    $new->widget = $this->widget->items($items, $encodeLabels);
    return $new;
}

            
itemsFromValues() public method

Fills items from an array provided. Array values are used for both input labels and input values.

public itemsFromValues( boolean[]|float[]|integer[]|string[]|\Stringable[] $values, boolean $encodeLabels true ): self
$values boolean[]|float[]|integer[]|string[]|\Stringable[]
$encodeLabels boolean

Whether labels should be encoded.

                public function itemsFromValues(array $values, bool $encodeLabels = true): self
{
    $new = clone $this;
    $new->widget = $this->widget->itemsFromValues($values, $encodeLabels);
    return $new;
}

            
label() public method
public label( string|null $content ): Yiisoft\Form\Field\CheckboxList
$content string|null

                final public function label(?string $content): static
{
    $new = clone $this;
    $new->label = $content;
    return $new;
}

            
labelAttributes() public method
public labelAttributes( array $attributes ): Yiisoft\Form\Field\CheckboxList
$attributes array

                final public function labelAttributes(array $attributes): static
{
    $new = clone $this;
    $new->labelAttributes = $attributes;
    $new->replaceLabelAttributes = true;
    return $new;
}

            
labelClass() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::labelClass()

Replace label tag CSS classes with a new set of classes.

public labelClass( string|null $class ): Yiisoft\Form\Field\CheckboxList
$class string|null

One or many CSS classes.

                final public function labelClass(?string ...$class): static
{
    $new = clone $this;
    $new->labelAttributes['class'] = $class;
    $new->replaceLabelClass = true;
    return $new;
}

            
labelConfig() public method
public labelConfig( array $config ): Yiisoft\Form\Field\CheckboxList
$config array

                final public function labelConfig(array $config): static
{
    $new = clone $this;
    $new->labelConfig = $config;
    return $new;
}

            
labelId() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::labelId()

Set label tag ID.

public labelId( string|null $id ): Yiisoft\Form\Field\CheckboxList
$id string|null

Label tag ID.

                final public function labelId(?string $id): static
{
    $new = clone $this;
    $new->labelAttributes['id'] = $id;
    return $new;
}

            
name() public method
public name( string|null $name ): Yiisoft\Form\Field\CheckboxList
$name string|null

                final public function name(?string $name): static
{
    $new = clone $this;
    $new->customName = $name;
    $new->useCustomName = true;
    return $new;
}

            
prepareContainerAttributes() protected method

protected prepareContainerAttributes( array &$attributes ): void
$attributes array

                protected function prepareContainerAttributes(array &$attributes): void
{
    $this->addValidationClassToAttributes(
        $attributes,
        $this->getInputData(),
        $this->hasCustomError() ? true : null,
    );
}

            
prepareValue() public method
public prepareValue( callable|null $callback ): Yiisoft\Form\Field\CheckboxList
$callback callable|null

                final public function prepareValue(?callable $callback): static
{
    $new = clone $this;
    $new->prepareValueCallback = $callback;
    return $new;
}

            
render() public method
public render( ): string

                final public function render(): string
{
    if ($this->isStartedByBegin) {
        $this->isStartedByBegin = false;
        return $this->renderEnd();
    }
    $this->beforeRender();
    $content = $this->generateContent();
    if ($content === null) {
        $this->enrichment = [];
        return '';
    }
    $result = $this->renderOpenContainerAndContent($content);
    if ($this->useContainer) {
        $result .= "\n" . Html::closeTag($this->containerTag);
    }
    $this->enrichment = [];
    return $result;
}

            
renderError() protected method

protected renderError( Yiisoft\Form\Field\Part\Error $error ): string
$error Yiisoft\Form\Field\Part\Error

                protected function renderError(Error $error): string
{
    return $error
        ->inputData($this->getInputData())
        ->render();
}

            
renderHint() protected method

protected renderHint( Yiisoft\Form\Field\Part\Hint $hint ): string
$hint Yiisoft\Form\Field\Part\Hint

                protected function renderHint(Hint $hint): string
{
    return $hint
        ->inputData($this->getInputData())
        ->render();
}

            
renderLabel() protected method

protected renderLabel( Yiisoft\Form\Field\Part\Label $label ): string
$label Yiisoft\Form\Field\Part\Label

                protected function renderLabel(Label $label): string
{
    return $label
        ->inputData($this->getInputData())
        ->useInputId(false)
        ->render();
}

            
separator() public method

public separator( string $separator ): self
$separator string

                public function separator(string $separator): self
{
    $new = clone $this;
    $new->widget = $this->widget->separator($separator);
    return $new;
}

            
shouldHideLabel() protected method
protected shouldHideLabel( ): boolean

                protected function shouldHideLabel(): bool
{
    return false;
}

            
template() public method

Defined in: Yiisoft\Form\Field\Base\PartsField::template()

Set layout template for render a field.

public template( string $template ): Yiisoft\Form\Field\CheckboxList
$template string

                final public function template(string $template): static
{
    $new = clone $this;
    $new->template = $template;
    return $new;
}

            
templateBegin() public method
public templateBegin( string $template ): Yiisoft\Form\Field\CheckboxList
$template string

                final public function templateBegin(string $template): static
{
    $new = clone $this;
    $new->templateBegin = $template;
    return $new;
}

            
templateEnd() public method
public templateEnd( string $template ): Yiisoft\Form\Field\CheckboxList
$template string

                final public function templateEnd(string $template): static
{
    $new = clone $this;
    $new->templateEnd = $template;
    return $new;
}

            
token() public method
public token( string $token, string|\Stringable $value ): Yiisoft\Form\Field\CheckboxList
$token string
$value string|\Stringable

                final public function token(string $token, string|Stringable $value): static
{
    $this->validateToken($token);
    $new = clone $this;
    $new->extraTokens[$token] = $value;
    return $new;
}

            
tokens() public method
public tokens( array $tokens ): Yiisoft\Form\Field\CheckboxList
$tokens array

                final public function tokens(array $tokens): static
{
    $new = clone $this;
    foreach ($tokens as $token => $value) {
        if (!is_string($token)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Token should be string. %s given.',
                    get_debug_type($token),
                ),
            );
        }
        if (!is_string($value) && !$value instanceof Stringable) {
            throw new InvalidArgumentException(
                sprintf(
                    'Token value should be string or Stringable. %s given.',
                    get_debug_type($value),
                ),
            );
        }
        $this->validateToken($token);
        $new->extraTokens[$token] = $value;
    }
    return $new;
}

            
uncheckValue() public method

public uncheckValue( boolean|float|integer|string|\Stringable|null $value ): self
$value boolean|float|integer|string|\Stringable|null

                public function uncheckValue(bool|float|int|string|Stringable|null $value): self
{
    $new = clone $this;
    $new->widget = $this->widget->uncheckValue($value);
    return $new;
}

            
useContainer() public method
public useContainer( boolean $use ): Yiisoft\Form\Field\CheckboxList
$use boolean

                final public function useContainer(bool $use): static
{
    $new = clone $this;
    $new->useContainer = $use;
    return $new;
}

            
validClass() public method
public validClass( string|null $class ): self
$class string|null

                public function validClass(?string $class): self
{
    $new = clone $this;
    $new->validClass = $class;
    return $new;
}

            
value() public method
public value( mixed $value ): Yiisoft\Form\Field\CheckboxList
$value mixed

                final public function value(mixed $value): static
{
    $new = clone $this;
    $new->customValue = $value;
    $new->useCustomValue = true;
    return $new;
}