0 follower

Final Class Yiisoft\Html\Tag\Input\Checkbox

InheritanceYiisoft\Html\Tag\Input\Checkbox » Yiisoft\Html\Tag\Base\BooleanInputTag » Yiisoft\Html\Tag\Base\InputTag » Yiisoft\Html\Tag\Base\VoidTag » Yiisoft\Html\Tag\Base\Tag
ImplementsYiisoft\Html\NoEncodeStringableInterface

Protected Properties

Hide inherited properties

Property Type Description Defined By
$attributes array Yiisoft\Html\Tag\Base\Tag

Method Details

Hide inherited methods

__toString() public method
public string __toString ( )

                final public function __toString(): string
{
    return $this->render();
}

            
addAttributes() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::addAttributes()

Add a set of attributes to existing tag attributes.

Same named attributes are replaced.

public Yiisoft\Html\Tag\Input\Checkbox addAttributes ( array $attributes )
$attributes array

Name-value set of attributes.

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

            
addClass() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::addClass()

Add one or more CSS classes to the tag.

public Yiisoft\Html\Tag\Input\Checkbox addClass ( \BackedEnum|string|null $class )
$class \BackedEnum|string|null

One or many CSS classes.

                final public function addClass(BackedEnum|string|null ...$class): static
{
    $new = clone $this;
    Html::addCssClass($new->attributes, $class);
    return $new;
}

            
addStyle() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::addStyle()

Add CSS styles to the tag.

See also Yiisoft\Html\Html::addCssStyle().

public Yiisoft\Html\Tag\Input\Checkbox addStyle ( string|string[] $style, boolean $overwrite true )
$style string|string[]

The new style string (e.g. 'width: 100px; height: 200px') or array (e.g. ['width' => '100px', 'height' => '200px']).

$overwrite boolean

Whether to overwrite existing CSS properties if the new style contain them too.

                final public function addStyle(array|string $style, bool $overwrite = true): static
{
    $new = clone $this;
    Html::addCssStyle($new->attributes, $style, $overwrite);
    return $new;
}

            
after() protected method
protected string after ( )

                final protected function after(): string
{
    if ($this->label === null) {
        return '';
    }
    if ($this->labelWrap) {
        $html = $this->label === '' ? '' : ' ';
    } else {
        $labelAttributes = array_merge($this->labelAttributes, [
            'for' => $this->attributes['id'],
        ]);
        $html = ' ' . $this->renderLabelOpenTag($labelAttributes);
    }
    $html .= $this->labelEncode ? Html::encode($this->label) : $this->label;
    $html .= '</label>';
    return $html;
}

            
attribute() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::attribute()

Set attribute value.

public Yiisoft\Html\Tag\Input\Checkbox attribute ( string $name, mixed $value )
$name string

Name of the attribute.

$value mixed

Value of the attribute.

                final public function attribute(string $name, mixed $value): static
{
    $new = clone $this;
    $new->attributes[$name] = $value;
    return $new;
}

            
attributes() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::attributes()

Replace attributes with a new set.

public Yiisoft\Html\Tag\Input\Checkbox attributes ( array $attributes )
$attributes array

Name-value set of attributes.

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

            
before() protected method
protected string before ( )

                final protected function before(): string
{
    $this->attributes['id'] ??= ($this->labelWrap || $this->label === null)
        ? null
        : Html::generateId();
    return $this->renderUncheckInput()
        . ($this->labelWrap ? $this->renderLabelOpenTag($this->labelAttributes) : '');
}

            
checked() public method
public Yiisoft\Html\Tag\Input\Checkbox checked ( boolean $checked true )
$checked boolean

Whether input it checked.

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

            
class() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::class()

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

public Yiisoft\Html\Tag\Input\Checkbox class ( \BackedEnum|string|null $class )
$class \BackedEnum|string|null

One or many CSS classes.

                final public function class(BackedEnum|string|null ...$class): static
{
    $new = clone $this;
    unset($new->attributes['class']);
    Html::addCssClass($new->attributes, $class);
    return $new;
}

            
disabled() public method
public Yiisoft\Html\Tag\Input\Checkbox disabled ( boolean $disabled true )
$disabled boolean

Whether input is disabled.

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

            
form() public method
public Yiisoft\Html\Tag\Input\Checkbox form ( string|null $formId )
$formId string|null

ID of the form input belongs to.

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

            
getName() protected method
protected string getName ( )

                protected function getName(): string
{
    return 'input';
}

            
getType() protected method

protected string getType ( )

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

            
id() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::id()

Set tag ID.

public Yiisoft\Html\Tag\Input\Checkbox id ( string|null $id )
$id string|null

Tag ID.

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

            
label() public method

Defined in: Yiisoft\Html\Tag\Base\BooleanInputTag::label()

Label that is wraps around attribute when rendered.

public Yiisoft\Html\Tag\Input\Checkbox label ( string|null $label, array $attributes = [], boolean $wrap true )
$label string|null

Input label.

$attributes array

Name-value set of label attributes.

$wrap boolean

Whether to wrap input with label tag. If set to false, label will be rendered aside with input.

                final public function label(
    ?string $label,
    array $attributes = [],
    bool $wrap = true,
): static {
    $new = clone $this;
    $new->label = $label;
    $new->labelAttributes = $attributes;
    $new->labelWrap = $wrap;
    return $new;
}

            
labelEncode() public method
public Yiisoft\Html\Tag\Input\Checkbox labelEncode ( boolean $encode )
$encode boolean

Whether to encode label content. Defaults to true.

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

            
name() public method
public Yiisoft\Html\Tag\Input\Checkbox name ( string|null $name )
$name string|null

Name of the input.

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

            
prepareAttributes() protected method
protected void prepareAttributes ( )

                final protected function prepareAttributes(): void
{
    $this->attributes['type'] = $this->getType();
}

            
readonly() public method
public Yiisoft\Html\Tag\Input\Checkbox readonly ( boolean $readOnly true )
$readOnly boolean

Whether input is read only.

                public function readonly(bool $readOnly = true): static
{
    $new = clone $this;
    $new->attributes['readonly'] = $readOnly;
    return $new;
}

            
removeStyle() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::removeStyle()

Remove CSS styles from the tag.

See also Yiisoft\Html\Html::removeCssStyle().

public Yiisoft\Html\Tag\Input\Checkbox removeStyle ( string|string[] $properties )
$properties string|string[]

The CSS properties to be removed. You may use a string if you are removing a single property.

                final public function removeStyle(string|array $properties): static
{
    $new = clone $this;
    Html::removeCssStyle($new->attributes, $properties);
    return $new;
}

            
render() public method
public string render ( )

                final public function render(): string
{
    return $this->before() . $this->renderTag() . $this->after();
}

            
renderAttributes() protected method

Defined in: Yiisoft\Html\Tag\Base\Tag::renderAttributes()

Render the current tag attributes.

See also Yiisoft\Html\Html::renderTagAttributes().

protected string renderAttributes ( )

                final protected function renderAttributes(): string
{
    $this->prepareAttributes();
    return Html::renderTagAttributes($this->attributes);
}

            
renderTag() protected method
protected string renderTag ( )

                final protected function renderTag(): string
{
    return '<' . $this->getName() . $this->renderAttributes() . '>';
}

            
required() public method
public Yiisoft\Html\Tag\Input\Checkbox required ( boolean $required true )
$required boolean

Whether input is required.

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

            
sideLabel() public method

Defined in: Yiisoft\Html\Tag\Base\BooleanInputTag::sideLabel()

Label that is rendered separately and is referring input by ID.

public Yiisoft\Html\Tag\Input\Checkbox sideLabel ( string|null $label, array $attributes = [] )
$label string|null

Input label.

$attributes array

Name-value set of label attributes.

                final public function sideLabel(?string $label, array $attributes = []): static
{
    $new = clone $this;
    $new->label = $label;
    $new->labelAttributes = $attributes;
    $new->labelWrap = false;
    return $new;
}

            
tag() public static method
public static Yiisoft\Html\Tag\Input\Checkbox tag ( )

                final public static function tag(): static
{
    return new static();
}

            
uncheckValue() public method
public Yiisoft\Html\Tag\Input\Checkbox uncheckValue ( boolean|float|integer|string|\Stringable|null $value )
$value boolean|float|integer|string|\Stringable|null

Value that corresponds to "unchecked" state of the input.

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

            
unionAttributes() public method

Defined in: Yiisoft\Html\Tag\Base\Tag::unionAttributes()

Union attributes with a new set.

public Yiisoft\Html\Tag\Input\Checkbox unionAttributes ( array $attributes )
$attributes array

Name-value set of attributes.

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

            
value() public method
public Yiisoft\Html\Tag\Input\Checkbox value ( boolean|float|integer|string|\Stringable|null $value )
$value boolean|float|integer|string|\Stringable|null

Value of the input.

                public function value(bool|float|int|string|Stringable|null $value): static
{
    $new = clone $this;
    $new->attributes['value'] = $value;
    return $new;
}