0 follower

Final Class Yiisoft\Form\Field\Button

InheritanceYiisoft\Form\Field\Button » Yiisoft\Form\Field\Base\ButtonField » Yiisoft\Form\Field\Base\PartsField » Yiisoft\Form\Field\Base\BaseField » Yiisoft\Widget\Widget
Uses TraitsYiisoft\Form\Field\Base\FieldContentTrait

Represents <button> element of type "button" are rendered as button without default behavior.

Public Methods

Hide inherited methods

Method Description Defined By
addButtonAttributes() Yiisoft\Form\Field\Base\ButtonField
addButtonClass() Add one or more CSS classes to the button tag. Yiisoft\Form\Field\Base\ButtonField
addContainerAttributes() Yiisoft\Form\Field\Base\BaseField
addContainerClass() Add one or more CSS classes to the container tag. Yiisoft\Form\Field\Base\BaseField
addContent() Yiisoft\Form\Field\Base\FieldContentTrait
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
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
ariaDescribedBy() Identifies the element (or elements) that describes the object. Yiisoft\Form\Field\Base\ButtonField
ariaLabel() Defines a string value that labels the current element. Yiisoft\Form\Field\Base\ButtonField
autofocus() Focus on the control (put cursor into it) when the page loads. Only one form element could be in focus at the same time. Yiisoft\Form\Field\Base\ButtonField
beforeInput() Yiisoft\Form\Field\Base\PartsField
begin() Yiisoft\Form\Field\Base\BaseField
button() Yiisoft\Form\Field\Base\ButtonField
buttonAttributes() Yiisoft\Form\Field\Base\ButtonField
buttonClass() Replace button tag CSS classes with a new set of classes. Yiisoft\Form\Field\Base\ButtonField
buttonId() Set button tag ID. Yiisoft\Form\Field\Base\ButtonField
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
content() Yiisoft\Form\Field\Base\FieldContentTrait
disabled() Yiisoft\Form\Field\Base\ButtonField
doubleEncodeContent() Yiisoft\Form\Field\Base\FieldContentTrait
encodeContent() Yiisoft\Form\Field\Base\FieldContentTrait
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 button belongs to. The value of this attribute must be the ID attribute of a form element in the same document. Yiisoft\Form\Field\Base\ButtonField
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
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
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\ButtonField
render() Yiisoft\Form\Field\Base\BaseField
tabIndex() The tabindex attribute indicates that its element can be focused, and where it participates in sequential keyboard navigation (usually with the Tab key, hence the name). Yiisoft\Form\Field\Base\ButtonField
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
useContainer() Yiisoft\Form\Field\Base\BaseField

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

addButtonAttributes() public method
public Yiisoft\Form\Field\Button addButtonAttributes ( array $attributes )
$attributes array

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

            
addButtonClass() public method

Defined in: Yiisoft\Form\Field\Base\ButtonField::addButtonClass()

Add one or more CSS classes to the button tag.

public Yiisoft\Form\Field\Button addButtonClass ( string|null $class )
$class string|null

One or many CSS classes.

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

            
addContainerAttributes() public method
public Yiisoft\Form\Field\Button addContainerAttributes ( array $attributes )
$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 Yiisoft\Form\Field\Button addContainerClass ( string|null $class )
$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;
}

            
addContent() public method
public Yiisoft\Form\Field\Button addContent ( string|\Stringable $content )
$content string|\Stringable

Field content.

                final public function addContent(string|Stringable ...$content): static
{
    $new = clone $this;
    $new->content = array_merge($new->content, array_values($content));
    return $new;
}

            
addErrorAttributes() public method
public Yiisoft\Form\Field\Button addErrorAttributes ( array $attributes )
$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 Yiisoft\Form\Field\Button addErrorClass ( string|null $class )
$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 Yiisoft\Form\Field\Button addHintAttributes ( array $attributes )
$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 Yiisoft\Form\Field\Button addHintClass ( string|null $class )
$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;
}

            
addInputContainerAttributes() public method
public Yiisoft\Form\Field\Button addInputContainerAttributes ( array $attributes )
$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 Yiisoft\Form\Field\Button addInputContainerClass ( string|null $class )
$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;
}

            
addLabelAttributes() public method
public Yiisoft\Form\Field\Button addLabelAttributes ( array $attributes )
$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 Yiisoft\Form\Field\Button addLabelClass ( string|null $class )
$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;
}

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

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

            
ariaDescribedBy() public method

Defined in: Yiisoft\Form\Field\Base\ButtonField::ariaDescribedBy()

Identifies the element (or elements) that describes the object.

public Yiisoft\Form\Field\Button ariaDescribedBy ( string|null $value )
$value string|null

                final public function ariaDescribedBy(?string ...$value): static
{
    $new = clone $this;
    $new->buttonAttributes['aria-describedby'] = array_filter($value, static fn (?string $v): bool => $v !== null);
    return $new;
}

            
ariaLabel() public method

Defined in: Yiisoft\Form\Field\Base\ButtonField::ariaLabel()

Defines a string value that labels the current element.

public Yiisoft\Form\Field\Button ariaLabel ( string|null $value )
$value string|null

                final public function ariaLabel(?string $value): static
{
    $new = clone $this;
    $new->buttonAttributes['aria-label'] = $value;
    return $new;
}

            
autofocus() public method

Defined in: Yiisoft\Form\Field\Base\ButtonField::autofocus()

Focus on the control (put cursor into it) when the page loads. Only one form element could be in focus at the same time.

public Yiisoft\Form\Field\Button autofocus ( boolean $value true )
$value boolean

                final public function autofocus(bool $value = true): static
{
    $new = clone $this;
    $new->buttonAttributes['autofocus'] = $value;
    return $new;
}

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

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

            
beforeRender() protected method
protected void beforeRender ( )

                protected function beforeRender(): void
{
}

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

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

            
button() public method
public Yiisoft\Form\Field\Button button ( \Yiisoft\Html\Tag\Button|null $button )
$button \Yiisoft\Html\Tag\Button|null

                final public function button(?Button $button): static
{
    $new = clone $this;
    $new->button = $button;
    return $new;
}

            
buttonAttributes() public method
public Yiisoft\Form\Field\Button buttonAttributes ( array $attributes )
$attributes array

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

            
buttonClass() public method

Defined in: Yiisoft\Form\Field\Base\ButtonField::buttonClass()

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

public Yiisoft\Form\Field\Button buttonClass ( string|null $class )
$class string|null

One or many CSS classes.

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

            
buttonId() public method

Defined in: Yiisoft\Form\Field\Base\ButtonField::buttonId()

Set button tag ID.

public Yiisoft\Form\Field\Button buttonId ( string|null $id )
$id string|null

Button tag ID.

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

            
containerAttributes() public method
public Yiisoft\Form\Field\Button containerAttributes ( array $attributes )
$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 Yiisoft\Form\Field\Button containerClass ( string|null $class )
$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 Yiisoft\Form\Field\Button containerId ( string|null $id )
$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 Yiisoft\Form\Field\Button containerTag ( string $tag )
$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;
}

            
content() public method
public Yiisoft\Form\Field\Button content ( string|\Stringable $content )
$content string|\Stringable

Field content.

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

            
disabled() public method
public Yiisoft\Form\Field\Button disabled ( boolean $disabled true )
$disabled boolean

                final public function disabled(bool $disabled = true): static
{
    $new = clone $this;
    $new->buttonAttributes['disabled'] = $disabled;
    return $new;
}

            
doubleEncodeContent() public method
public Yiisoft\Form\Field\Button doubleEncodeContent ( boolean $doubleEncode )
$doubleEncode boolean

Whether already encoded HTML entities in field content should be encoded. Defaults to true.

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

            
encodeContent() public method
public Yiisoft\Form\Field\Button encodeContent ( boolean|null $encode )
$encode boolean|null

Whether to encode field content. Supported values:

  • null: stringable objects that implement interface {@see \Yiisoft\Html\NoEncodeStringableInterface} are not encoded, everything else is encoded;
  • true: any content is encoded;
  • false: nothing is encoded. Defaults to null.

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

            
error() public method
public Yiisoft\Form\Field\Button error ( string|null $message, string $messages )
$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 Yiisoft\Form\Field\Button errorAttributes ( array $attributes )
$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 Yiisoft\Form\Field\Button errorClass ( string|null $class )
$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 Yiisoft\Form\Field\Button errorConfig ( array $config )
$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 Yiisoft\Form\Field\Button errorId ( string|null $id )
$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

Defined in: Yiisoft\Form\Field\Base\ButtonField::form()

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

public Yiisoft\Form\Field\Button form ( string|null $id )
$id string|null

ID of a form.

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

            
generateBeginContent() protected method
protected string generateBeginContent ( )

                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 string generateBeginInput ( )

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

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

                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 string generateEndContent ( )

                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 string generateEndInput ( )

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

            
generateInput() protected method
protected string generateInput ( )

                final protected function generateInput(): string
{
    $button = ($this->button ?? Button::tag())
        ->type($this->getType());
    if (!empty($this->buttonAttributes)) {
        $button = $button->addAttributes($this->buttonAttributes);
    }
    $content = $this->renderContent();
    if ($content !== '') {
        $button = $button->content($content);
    }
    return $button->render();
}

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

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

            
getType() protected method

protected string getType ( )

                protected function getType(): string
{
    return 'button';
}

            
hasCustomError() protected method
protected boolean hasCustomError ( )

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

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

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

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

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

            
hintAttributes() public method
public Yiisoft\Form\Field\Button hintAttributes ( array $attributes )
$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 Yiisoft\Form\Field\Button hintClass ( string|null $class )
$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 Yiisoft\Form\Field\Button hintConfig ( array $config )
$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 Yiisoft\Form\Field\Button hintId ( string|null $id )
$id string|null

Hint tag ID.

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

            
inputContainerAttributes() public method
public Yiisoft\Form\Field\Button inputContainerAttributes ( array $attributes )
$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 Yiisoft\Form\Field\Button inputContainerClass ( string|null $class )
$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 Yiisoft\Form\Field\Button inputContainerTag ( string|null $tag )
$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;
}

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

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

            
labelAttributes() public method
public Yiisoft\Form\Field\Button labelAttributes ( array $attributes )
$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 Yiisoft\Form\Field\Button labelClass ( string|null $class )
$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 Yiisoft\Form\Field\Button labelConfig ( array $config )
$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 Yiisoft\Form\Field\Button labelId ( string|null $id )
$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 self name ( string|null $name )
$name string|null

                final public function name(?string $name): self
{
    $new = clone $this;
    $new->buttonAttributes['name'] = $name;
    return $new;
}

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

                protected function prepareContainerAttributes(array &$attributes): void
{
}

            
render() public method
public string render ( )

                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;
}

            
renderContent() protected method
protected string renderContent ( )
return string

Obtain field content considering encoding options {@see \Yiisoft\Form\Field\Base\encodeContent()}.

                final protected function renderContent(): string
{
    $content = '';
    foreach ($this->content as $item) {
        if ($this->encodeContent || ($this->encodeContent === null && !($item instanceof NoEncodeStringableInterface))) {
            $item = Html::encode($item, $this->doubleEncodeContent);
        }
        $content .= $item;
    }
    return $content;
}

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

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

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

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

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

                protected function renderLabel(Label $label): string
{
    return $label->render();
}

            
shouldHideLabel() protected method
protected boolean shouldHideLabel ( )

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

            
tabIndex() public method

Defined in: Yiisoft\Form\Field\Base\ButtonField::tabIndex()

The tabindex attribute indicates that its element can be focused, and where it participates in sequential keyboard navigation (usually with the Tab key, hence the name).

It accepts an integer as a value, with different results depending on the integer's value:

  • A negative value (usually tabindex="-1") means that the element is not reachable via sequential keyboard navigation, but could be focused with Javascript or visually. It's mostly useful to create accessible widgets with JavaScript.
  • tabindex="0" means that the element should be focusable in sequential keyboard navigation, but its order is defined by the document's source order.
  • A positive value means the element should be focusable in sequential keyboard navigation, with its order defined by the value of the number. That is, tabindex="4" is focused before tabindex="5", but after tabindex="3".
public Yiisoft\Form\Field\Button tabIndex ( integer|null $value )
$value integer|null

                final public function tabIndex(?int $value): static
{
    $new = clone $this;
    $new->buttonAttributes['tabindex'] = $value;
    return $new;
}

            
template() public method

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

Set layout template for render a field.

public Yiisoft\Form\Field\Button template ( string $template )
$template string

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

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

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

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

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

            
token() public method
public Yiisoft\Form\Field\Button token ( string $token, string|\Stringable $value )
$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 Yiisoft\Form\Field\Button tokens ( array $tokens )
$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;
}

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

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