Final Class Yiisoft\Html\Tag\Input\Radio
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $attributes | array | Yiisoft\ |
Public Methods
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| after() | Yiisoft\ |
|
| before() | Yiisoft\ |
|
| getName() | Yiisoft\ |
|
| getType() | Yiisoft\ |
|
| prepareAttributes() | Yiisoft\ |
|
| renderAttributes() | Render the current tag attributes. | Yiisoft\ |
| renderTag() | Yiisoft\ |
Method Details
Defined in:
Yiisoft\
| public mixed __construct ( ) |
final public function __construct() {}
Defined in:
Yiisoft\
| public string __toString ( ) |
final public function __toString(): string
{
return $this->render();
}
Defined in:
Yiisoft\
Add a set of attributes to existing tag attributes.
Same named attributes are replaced.
| public static 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;
}
Defined in:
Yiisoft\
Add one or more CSS classes to the tag.
| public static addClass ( \ | ||
| $class | \ |
One or many CSS classes. |
final public function addClass(BackedEnum|string|null ...$class): static
{
$new = clone $this;
Html::addCssClass($new->attributes, $class);
return $new;
}
Defined in:
Yiisoft\
Add CSS styles to the tag.
See also Yiisoft\
| public static addStyle ( string|string[] $style, boolean $overwrite = true ) | ||
| $style | string|string[] |
The new style string (e.g. |
| $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;
}
Defined in:
Yiisoft\
| protected string after ( ) |
final protected function after(): string
{
$html = (string) $this->afterInput;
if ($this->label === null) {
return $html;
}
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;
}
| public static afterInput ( string|\ | ||
| $content | string|\ |
Content to be rendered after the input. |
final public function afterInput(string|Stringable $content): static
{
$new = clone $this;
$new->afterInput = $content;
return $new;
}
Defined in:
Yiisoft\
Set attribute value.
| public static 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;
}
Defined in:
Yiisoft\
Replace attributes with a new set.
| public static 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;
}
Defined in:
Yiisoft\
| protected string before ( ) |
final protected function before(): string
{
$this->attributes['id'] ??= ($this->labelWrap || $this->label === null)
? null
: Html::generateId();
$html = $this->renderUncheckInput();
if ($this->labelWrap) {
$html .= $this->renderLabelOpenTag($this->labelAttributes);
}
$html .= $this->beforeInput;
return $html;
}
| public static beforeInput ( string|\ | ||
| $content | string|\ |
Content to be rendered before the input. |
final public function beforeInput(string|Stringable $content): static
{
$new = clone $this;
$new->beforeInput = $content;
return $new;
}
Defined in:
Yiisoft\
| public static 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;
}
Defined in:
Yiisoft\
Replace current tag CSS classes with a new set of classes.
| public static class ( \ | ||
| $class | \ |
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;
}
Defined in:
Yiisoft\
| public static 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;
}
Defined in:
Yiisoft\
| public static 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;
}
Defined in:
Yiisoft\
| protected string getName ( ) |
protected function getName(): string
{
return 'input';
}
Defined in:
Yiisoft\
Set tag ID.
| public static id ( string|null $id ) | ||
| $id | string|null |
Non-empty tag ID. |
final public function id(?string $id): static
{
/** @psalm-suppress TypeDoesNotContainType */
if ($id === '') {
throw new LogicException('The tag id cannot be an empty string.');
}
$new = clone $this;
$new->attributes['id'] = $id;
return $new;
}
Defined in:
Yiisoft\
Label that is wraps around attribute when rendered.
| public static 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 |
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;
}
| public static labelEncode ( boolean $encode ) | ||
| $encode | boolean |
Whether to encode label content. Defaults to |
final public function labelEncode(bool $encode): static
{
$new = clone $this;
$new->labelEncode = $encode;
return $new;
}
Defined in:
Yiisoft\
| public static 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;
}
| protected void prepareAttributes ( ) |
final protected function prepareAttributes(): void
{
$this->attributes['type'] = $this->getType();
}
Defined in:
Yiisoft\
| public static 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;
}
Defined in:
Yiisoft\
Remove CSS styles from the tag.
See also Yiisoft\
| public static 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;
}
Defined in:
Yiisoft\
| public string render ( ) |
final public function render(): string
{
return $this->before() . $this->renderTag() . $this->after();
}
Defined in:
Yiisoft\
Render the current tag attributes.
See also Yiisoft\
| protected string renderAttributes ( ) |
final protected function renderAttributes(): string
{
$this->prepareAttributes();
return Html::renderTagAttributes($this->attributes);
}
Defined in:
Yiisoft\
| protected string renderTag ( ) |
final protected function renderTag(): string
{
return '<' . $this->getName() . $this->renderAttributes() . '>';
}
Defined in:
Yiisoft\
| public static 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;
}
Defined in:
Yiisoft\
Label that is rendered separately and is referring input by ID.
| public static 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;
}
Defined in:
Yiisoft\
| public static static tag ( ) |
final public static function tag(): static
{
return new static();
}
| public static uncheckValue ( boolean|float|integer|string|\ | ||
| $value | boolean|float|integer|string|\ |
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;
}
Defined in:
Yiisoft\
Union attributes with a new set.
| public static 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;
}
Defined in:
Yiisoft\
| public static value ( boolean|float|integer|string|\ | ||
| $value | boolean|float|integer|string|\ |
Value of the input. |
public function value(bool|float|int|string|Stringable|null $value): static
{
$new = clone $this;
$new->attributes['value'] = $value;
return $new;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.