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 Yiisoft\Form\Field\ErrorSummary addContainerAttributes ( array $attributes ) | ||
| $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 Yiisoft\Form\Field\ErrorSummary 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;
}
Add one or more CSS classes to the list container tag.
| public self addListClass ( string|null $class ) | ||
| $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 void beforeRender ( ) |
protected function beforeRender(): void
{
}
Defined in: Yiisoft\Form\Field\Base\BaseField::begin()
| public string|null begin ( ) |
final public function begin(): ?string
{
parent::begin();
$this->isStartedByBegin = true;
$this->beforeRender();
$content = $this->generateBeginContent();
return $this->renderOpenContainerAndContent($content);
}
| public Yiisoft\Form\Field\ErrorSummary containerAttributes ( array $attributes ) | ||
| $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 Yiisoft\Form\Field\ErrorSummary 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;
}
Defined in: Yiisoft\Form\Field\Base\BaseField::containerId()
Set container tag ID.
| public Yiisoft\Form\Field\ErrorSummary 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;
}
| public Yiisoft\Form\Field\ErrorSummary 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;
}
Whether error content should be HTML-encoded.
| public self encode ( boolean $value ) | ||
| $value | boolean | |
public function encode(bool $value): self
{
$new = clone $this;
$new->encode = $value;
return $new;
}
| public self errors ( array $errors ) | ||
| $errors | array | |
public function errors(array $errors): self
{
$new = clone $this;
$new->errors = $errors;
return $new;
}
| protected string generateBeginContent ( ) |
protected function generateBeginContent(): string
{
return '';
}
| protected string|null generateContent ( ) |
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 string generateEndContent ( ) |
protected function generateEndContent(): string
{
return '';
}
| 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) ?? [];
}
Set the header text for the error summary
| public self header ( string $value ) | ||
| $value | string | |
public function header(string $value): self
{
$new = clone $this;
$new->header = $value;
return $new;
}
Set header attributes for the error summary.
| public self headerAttributes ( array $values ) | ||
| $values | array |
Attribute values indexed by attribute names. See {@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 self headerEncode ( boolean $encode ) | ||
| $encode | boolean | |
public function headerEncode(bool $encode): self
{
$new = clone $this;
$new->headerEncode = $encode;
return $new;
}
Set the header tag name.
| public self headerTag ( string|null $tag ) | ||
| $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 self listAttributes ( array $attributes ) | ||
| $attributes | array |
Attribute values indexed by attribute names. See {@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 self listClass ( string|null $class ) | ||
| $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 self onlyCommonErrors ( ) |
public function onlyCommonErrors(): self
{
$new = clone $this;
$new->onlyProperties = [''];
return $new;
}
| public self onlyFirst ( boolean $value = true ) | ||
| $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 self onlyProperties ( array $names ) | ||
| $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 void prepareContainerAttributes ( array &$attributes ) | ||
| $attributes | array | |
protected function prepareContainerAttributes(array &$attributes): void
{
}
Defined in: Yiisoft\Form\Field\Base\BaseField::render()
| 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;
}
| public Yiisoft\Form\Field\ErrorSummary useContainer ( boolean $use ) | ||
| $use | boolean | |
final public function useContainer(bool $use): static
{
$new = clone $this;
$new->useContainer = $use;
return $new;
}
Signup or Login in order to comment.