Abstract Class Yiisoft\Form\Field\Base\BaseField
Protected Properties
Public 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 |
| 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 | |
| render() | Yiisoft\Form\Field\Base\BaseField | |
| useContainer() | Yiisoft\Form\Field\Base\BaseField |
Protected Methods
Property Details
Method Details
| public addContainerAttributes( array $attributes ): Yiisoft\Form\Field\Base\BaseField | ||
| $attributes | array | |
final public function addContainerAttributes(array $attributes): static
{
$new = clone $this;
$new->containerAttributes = array_merge($new->containerAttributes, $attributes);
return $new;
}
Add one or more CSS classes to the container tag.
| public addContainerClass( string|null $class ): Yiisoft\Form\Field\Base\BaseField | ||
| $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;
}
| 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\Base\BaseField | ||
| $attributes | array | |
final public function containerAttributes(array $attributes): static
{
$new = clone $this;
$new->containerAttributes = $attributes;
return $new;
}
Replace container tag CSS classes with a new set of classes.
| public containerClass( string|null $class ): Yiisoft\Form\Field\Base\BaseField | ||
| $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;
}
Set container tag ID.
| public containerId( string|null $id ): Yiisoft\Form\Field\Base\BaseField | ||
| $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\Base\BaseField | ||
| $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;
}
| protected generateBeginContent( ): string |
protected function generateBeginContent(): string
{
return '';
}
| protected abstract generateContent( ): string|null |
abstract protected function generateContent(): ?string;
| 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) ?? [];
}
| protected prepareContainerAttributes( array &$attributes ): void | ||
| $attributes | array | |
protected function prepareContainerAttributes(array &$attributes): void {}
| 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\Base\BaseField | ||
| $use | boolean | |
final public function useContainer(bool $use): static
{
$new = clone $this;
$new->useContainer = $use;
return $new;
}
Signup or Login in order to comment.