Final Class Yiisoft\Form\Field\ErrorSummary
| Inheritance | Yiisoft\Form\Field\ErrorSummary » Yiisoft\Form\Field\Base\BaseField » Yiisoft\Widget\Widget |
|---|
Protected Properties
Public Methods
Protected Methods
Method Details
| public addContainerAttributes( array $attributes ): Yiisoft\Form\Field\ErrorSummary | ||
| $attributes | array | |
final public function addContainerAttributes(array $attributes): static
{
$new = clone $this;
$new->containerAttributes = array_merge($new->containerAttributes, $attributes);
return $new;
}
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\ErrorSummary | ||
| $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;
}
Add one or more CSS classes to the list container tag.
| public addListClass( string|null $class ): self | ||
| $class | string|null |
One or many CSS classes. |
public function addListClass(?string ...$class): self
{
$new = clone $this;
Html::addCssClass($new->listAttributes, $class);
return $new;
}
| protected beforeRender( ): void |
protected function beforeRender(): void {}
Defined in: Yiisoft\Form\Field\Base\BaseField::begin()
| public begin( ): string|null |
final public function begin(): ?string
{
parent::begin();
$this->isStartedByBegin = true;
$this->beforeRender();
$content = $this->generateBeginContent();
return $this->renderOpenContainerAndContent($content);
}
| public containerAttributes( array $attributes ): Yiisoft\Form\Field\ErrorSummary | ||
| $attributes | array | |
final public function containerAttributes(array $attributes): static
{
$new = clone $this;
$new->containerAttributes = $attributes;
return $new;
}
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\ErrorSummary | ||
| $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;
}
Defined in: Yiisoft\Form\Field\Base\BaseField::containerId()
Set container tag ID.
| public containerId( string|null $id ): Yiisoft\Form\Field\ErrorSummary | ||
| $id | string|null |
Container tag ID. |
final public function containerId(?string $id): static
{
$new = clone $this;
$new->containerAttributes['id'] = $id;
return $new;
}
| public containerTag( string $tag ): Yiisoft\Form\Field\ErrorSummary | ||
| $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;
}
Whether error content should be HTML-encoded.
| public encode( boolean $value ): self | ||
| $value | boolean | |
public function encode(bool $value): self
{
$new = clone $this;
$new->encode = $value;
return $new;
}
| public errors( array $errors ): self | ||
| $errors | array | |
public function errors(array $errors): self
{
$new = clone $this;
$new->errors = $errors;
return $new;
}
| protected generateBeginContent( ): string |
protected function generateBeginContent(): string
{
return '';
}
| protected generateContent( ): string|null |
protected function generateContent(): ?string
{
$errors = $this->filterErrors();
if (empty($errors)) {
return null;
}
$content = [];
if ($this->header !== '') {
$content[] = $this->headerTag === null
? ($this->headerEncode ? Html::encode($this->header) : $this->header)
: CustomTag::name($this->headerTag)
->attributes($this->headerAttributes)
->content($this->header)
->encode($this->headerEncode)
->render();
}
$content[] = Html::ul()
->attributes($this->listAttributes)
->strings($errors, [], $this->encode)
->render();
if ($this->footer !== '') {
$content[] = Html::div($this->footer, $this->footerAttributes)->render();
}
return implode("\n", $content);
}
| protected generateEndContent( ): string |
protected function generateEndContent(): string
{
return '';
}
| 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) ?? [];
}
Set the header text for the error summary
| public header( string $value ): self | ||
| $value | string | |
public function header(string $value): self
{
$new = clone $this;
$new->header = $value;
return $new;
}
Set header attributes for the error summary.
| public headerAttributes( array $values ): self | ||
| $values | array |
Attribute values indexed by attribute names. See \Yiisoft\Html\Html::renderTagAttributes for details on how attributes are being rendered. |
public function headerAttributes(array $values): self
{
$new = clone $this;
$new->headerAttributes = $values;
return $new;
}
Whether header content should be HTML-encoded.
| public headerEncode( boolean $encode ): self | ||
| $encode | boolean | |
public function headerEncode(bool $encode): self
{
$new = clone $this;
$new->headerEncode = $encode;
return $new;
}
Set the header tag name.
| public headerTag( string|null $tag ): self | ||
| $tag | string|null |
Header tag name. |
public function headerTag(?string $tag): self
{
if ($tag === '') {
throw new InvalidArgumentException('Tag name cannot be empty.');
}
$new = clone $this;
$new->headerTag = $tag;
return $new;
}
Set errors list container attributes.
| public listAttributes( array $attributes ): self | ||
| $attributes | array |
Attribute values indexed by attribute names. See \Yiisoft\Html\Html::renderTagAttributes for details on how attributes are being rendered. |
public function listAttributes(array $attributes): self
{
$new = clone $this;
$new->listAttributes = $attributes;
return $new;
}
Replace current list container tag CSS classes with a new set of classes.
| public listClass( string|null $class ): self | ||
| $class | string|null |
One or many CSS classes. |
public function listClass(?string ...$class): self
{
$new = clone $this;
$new->listAttributes['class'] = $class;
return $new;
}
Use only common errors when rendering the error summary.
| public onlyCommonErrors( ): self |
public function onlyCommonErrors(): self
{
$new = clone $this;
$new->onlyProperties = [''];
return $new;
}
| public onlyFirst( boolean $value = true ): self | ||
| $value | boolean | |
public function onlyFirst(bool $value = true): self
{
$new = clone $this;
$new->onlyFirst = $value;
return $new;
}
Specific properties to be filtered out when rendering the error summary.
| public onlyProperties( array $names ): self | ||
| $names | array |
The property names to be included in error summary. |
public function onlyProperties(string ...$names): self
{
$new = clone $this;
$new->onlyProperties = $names;
return $new;
}
| protected prepareContainerAttributes( array &$attributes ): void | ||
| $attributes | array | |
protected function prepareContainerAttributes(array &$attributes): void {}
Defined in: Yiisoft\Form\Field\Base\BaseField::render()
| 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;
}
| public useContainer( boolean $use ): Yiisoft\Form\Field\ErrorSummary | ||
| $use | boolean | |
final public function useContainer(bool $use): static
{
$new = clone $this;
$new->useContainer = $use;
return $new;
}
Signup or Login in order to comment.