Final Class Yiisoft\Html\Tag\Table
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $attributes | array | Yiisoft\ |
Public Methods
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| after() | Yiisoft\ |
|
| before() | Yiisoft\ |
|
| generateContent() | Yiisoft\ |
|
| getName() | Yiisoft\ |
|
| prepareAttributes() | Yiisoft\ |
|
| prepend() | 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;
}
| public self addBody ( Yiisoft\ | ||
| $body | Yiisoft\ |
One or more body ({@see \ |
public function addBody(Tbody ...$body): self
{
$new = clone $this;
$new->body = array_merge($new->body, $body);
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;
}
| public self addColumnGroups ( Yiisoft\ | ||
| $columnGroups | Yiisoft\ |
One or more column groups ({@see \ |
public function addColumnGroups(Colgroup ...$columnGroups): self
{
$new = clone $this;
$new->columnGroups = array_merge($new->columnGroups, $columnGroups);
return $new;
}
| public self addColumns ( Yiisoft\ | ||
| $columns | Yiisoft\ |
One or more columns ({@see \ |
public function addColumns(Col ...$columns): self
{
$new = clone $this;
$new->columns = array_merge($new->columns, $columns);
return $new;
}
| public self addRows ( Yiisoft\ | ||
| $rows | Yiisoft\ |
One or more rows ({@see \ |
public function addRows(Tr ...$rows): self
{
$new = clone $this;
$new->rows = array_merge($new->rows, $rows);
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 ( ) |
protected function after(): string
{
return '';
}
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 ( ) |
protected function before(): string
{
return '';
}
| public self body ( Yiisoft\ | ||
| $body | Yiisoft\ |
One or more body ({@see \ |
public function body(Tbody ...$body): self
{
$new = clone $this;
$new->body = $body;
return $new;
}
| public self caption ( ?\ | ||
| $caption | ?\ |
|
public function caption(?Caption $caption): self
{
$new = clone $this;
$new->caption = $caption;
return $new;
}
| public self captionString ( string|\ | ||
| $content | string|\ |
|
| $encode | boolean | |
public function captionString(string|Stringable|int|float|null $content, bool $encode = true): self
{
$caption = (new Caption())->content($content);
if (!$encode) {
$caption = $caption->encode(false);
}
return $this->caption($caption);
}
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 string close ( ) | ||
| return | string |
Closing tag. |
|---|---|---|
final public function close(): string
{
return '</' . $this->getName() . '>';
}
| public self columnGroups ( Yiisoft\ | ||
| $columnGroups | Yiisoft\ |
One or more column groups ({@see \ |
public function columnGroups(Colgroup ...$columnGroups): self
{
$new = clone $this;
$new->columnGroups = $columnGroups;
return $new;
}
| public self columns ( Yiisoft\ | ||
| $columns | Yiisoft\ |
One or more columns ({@see \ |
public function columns(Col ...$columns): self
{
$new = clone $this;
$new->columns = $columns;
return $new;
}
| protected string generateContent ( ) |
protected function generateContent(): string
{
$items = [];
if ($this->caption !== null) {
$items[] = $this->caption;
}
$items = array_merge(
$items,
$this->columnGroups,
$this->columns,
);
if ($this->header !== null) {
$items[] = $this->header;
}
$items = array_merge(
$items,
$this->body,
$this->rows,
);
if ($this->footer !== null) {
$items[] = $this->footer;
}
return $items
? "\n" . implode("\n" , $items) . "\n"
: '';
}
| public self header ( ?\ | ||
| $header | ?\ |
|
public function header(?Thead $header): self
{
$new = clone $this;
$new->header = $header;
return $new;
}
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\
| public string open ( ) | ||
| return | string |
Opening tag. |
|---|---|---|
final public function open(): string
{
return '<' . $this->getName() . $this->renderAttributes() . '>' . $this->prepend();
}
Defined in:
Yiisoft\
| protected void prepareAttributes ( ) |
protected function prepareAttributes(): void {}
Defined in:
Yiisoft\
| protected string prepend ( ) |
protected function prepend(): string
{
return '';
}
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->open() . $this->generateContent() . $this->close();
}
| public self rows ( Yiisoft\ | ||
| $rows | Yiisoft\ |
One or more rows ({@see \ |
public function rows(Tr ...$rows): self
{
$new = clone $this;
$new->rows = $rows;
return $new;
}
Defined in:
Yiisoft\
| public static static tag ( ) |
final public static function tag(): static
{
return new static();
}
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;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.