0 follower

Final Class Yiisoft\Form\Field\ErrorSummary

InheritanceYiisoft\Form\Field\ErrorSummary » Yiisoft\Form\Field\Base\BaseField » Yiisoft\Widget\Widget

Psalm Types

Name Value
Errors array<string, list<string>>

Public Methods

Hide inherited methods

Method Description Defined By
addContainerAttributes() Yiisoft\Form\Field\Base\BaseField
addContainerClass() Add one or more CSS classes to the container tag. Yiisoft\Form\Field\Base\BaseField
addListClass() Add one or more CSS classes to the list container tag. Yiisoft\Form\Field\ErrorSummary
begin() Yiisoft\Form\Field\Base\BaseField
containerAttributes() Yiisoft\Form\Field\Base\BaseField
containerClass() Replace container tag CSS classes with a new set of classes. Yiisoft\Form\Field\Base\BaseField
containerId() Set container tag ID. Yiisoft\Form\Field\Base\BaseField
containerTag() Yiisoft\Form\Field\Base\BaseField
encode() Whether error content should be HTML-encoded. Yiisoft\Form\Field\ErrorSummary
errors() Yiisoft\Form\Field\ErrorSummary
footer() Set the footer text for the error summary Yiisoft\Form\Field\ErrorSummary
footerAttributes() Set footer attributes for the error summary. Yiisoft\Form\Field\ErrorSummary
header() Set the header text for the error summary Yiisoft\Form\Field\ErrorSummary
headerAttributes() Set header attributes for the error summary. Yiisoft\Form\Field\ErrorSummary
headerEncode() Whether header content should be HTML-encoded. Yiisoft\Form\Field\ErrorSummary
headerTag() Set the header tag name. Yiisoft\Form\Field\ErrorSummary
listAttributes() Set errors list container attributes. Yiisoft\Form\Field\ErrorSummary
listClass() Replace current list container tag CSS classes with a new set of classes. Yiisoft\Form\Field\ErrorSummary
onlyCommonErrors() Use only common errors when rendering the error summary. Yiisoft\Form\Field\ErrorSummary
onlyFirst() Yiisoft\Form\Field\ErrorSummary
onlyProperties() Specific properties to be filtered out when rendering the error summary. Yiisoft\Form\Field\ErrorSummary
render() Yiisoft\Form\Field\Base\BaseField
useContainer() Yiisoft\Form\Field\Base\BaseField

Method Details

Hide inherited methods

addContainerAttributes() public method
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;
}

            
addContainerClass() public method

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;
}

            
addListClass() public method

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;
}

            
beforeRender() protected method
protected void beforeRender ( )

                protected function beforeRender(): void
{
}

            
begin() public method
public string|null begin ( )

                final public function begin(): ?string
{
    parent::begin();
    $this->isStartedByBegin = true;
    $this->beforeRender();
    $content = $this->generateBeginContent();
    return $this->renderOpenContainerAndContent($content);
}

            
containerAttributes() public method
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;
}

            
containerClass() public method

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;
}

            
containerId() public method

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;
}

            
containerTag() public method
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;
}

            
encode() public method

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;
}

            
errors() public method

public self errors ( array $errors )
$errors array

                public function errors(array $errors): self
{
    $new = clone $this;
    $new->errors = $errors;
    return $new;
}

            
footer() public method

Set the footer text for the error summary

public self footer ( string $value )
$value string

                public function footer(string $value): self
{
    $new = clone $this;
    $new->footer = $value;
    return $new;
}

            
footerAttributes() public method

Set footer attributes for the error summary.

public self footerAttributes ( 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 footerAttributes(array $values): self
{
    $new = clone $this;
    $new->footerAttributes = $values;
    return $new;
}

            
generateBeginContent() protected method
protected string generateBeginContent ( )

                protected function generateBeginContent(): string
{
    return '';
}

            
generateContent() protected method

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);
}

            
generateEndContent() protected method
protected string generateEndContent ( )

                protected function generateEndContent(): string
{
    return '';
}

            
getThemeConfig() protected static method
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) ?? [];
}

            
header() public method

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;
}

            
headerAttributes() public method

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;
}

            
headerEncode() public method

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;
}

            
headerTag() public method

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;
}

            
listAttributes() public method

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;
}

            
listClass() public method

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;
}

            
onlyCommonErrors() public method

Use only common errors when rendering the error summary.

public self onlyCommonErrors ( )

                public function onlyCommonErrors(): self
{
    $new = clone $this;
    $new->onlyProperties = [''];
    return $new;
}

            
onlyFirst() public method

public self onlyFirst ( boolean $value true )
$value boolean

                public function onlyFirst(bool $value = true): self
{
    $new = clone $this;
    $new->onlyFirst = $value;
    return $new;
}

            
onlyProperties() public method

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;
}

            
prepareContainerAttributes() protected method
protected void prepareContainerAttributes ( array &$attributes )
$attributes array

                protected function prepareContainerAttributes(array &$attributes): void
{
}

            
render() public method
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;
}

            
useContainer() public method
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;
}