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 Yiisoft\Form\Field\Base\BaseField addContainerAttributes ( array $attributes ) | ||
| $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 Yiisoft\Form\Field\Base\BaseField 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;
}
| 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\Base\BaseField containerAttributes ( array $attributes ) | ||
| $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 Yiisoft\Form\Field\Base\BaseField 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;
}
Set container tag ID.
| public Yiisoft\Form\Field\Base\BaseField 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\Base\BaseField 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;
}
| protected string generateBeginContent ( ) |
protected function generateBeginContent(): string
{
return '';
}
| protected abstract string|null generateContent ( ) |
abstract protected function generateContent(): ?string;
| 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) ?? [];
}
| protected void prepareContainerAttributes ( array &$attributes ) | ||
| $attributes | array | |
protected function prepareContainerAttributes(array &$attributes): void
{
}
| 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\Base\BaseField 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.