0 follower

Final Class Yiisoft\Form\Field\Part\Hint

InheritanceYiisoft\Form\Field\Part\Hint » Yiisoft\Widget\Widget
Uses TraitsYiisoft\Form\Field\Base\InputData\InputDataTrait

Represents hint for a form field.

Method Details

Hide inherited methods

addAttributes() public method

public self addAttributes ( array $attributes )
$attributes array

                public function addAttributes(array $attributes): self
{
    $new = clone $this;
    $new->attributes = array_merge($this->attributes, $attributes);
    return $new;
}

            
addClass() public method

Add one or more CSS classes to the tag.

public self addClass ( string|null $class )
$class string|null

One or many CSS classes.

                public function addClass(?string ...$class): self
{
    $new = clone $this;
    Html::addCssClass($new->attributes, $class);
    return $new;
}

            
attributes() public method

public self attributes ( array $attributes )
$attributes array

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

            
class() public method

Replace tag CSS classes with a new set of classes.

public self class ( string|null $class )
$class string|null

One or many CSS classes.

                public function class(?string ...$class): self
{
    $new = clone $this;
    $new->attributes['class'] = array_filter($class, static fn ($c) => $c !== null);
    return $new;
}

            
content() public method

public self content ( string|\Stringable|null $content )
$content string|\Stringable|null

                public function content(string|Stringable|null $content): self
{
    $new = clone $this;
    $new->content = $content;
    return $new;
}

            
encode() public method

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

            
getInputData() protected method
protected Yiisoft\Form\Field\Base\InputData\InputDataInterface getInputData ( )

                final protected function getInputData(): InputDataInterface
{
    if ($this->inputData === null) {
        $this->inputData = new InputData();
    }
    return $this->inputData;
}

            
getThemeConfig() protected static method

protected static array getThemeConfig ( string|null $theme )
$theme string|null

                protected static function getThemeConfig(?string $theme): array
{
    return ThemeContainer::getTheme($theme)?->getHintConfig() ?? [];
}

            
id() public method

Set tag ID.

public self id ( string|null $id )
$id string|null

Tag ID.

                public function id(?string $id): self
{
    $new = clone $this;
    $new->attributes['id'] = $id;
    return $new;
}

            
inputData() public method
public Yiisoft\Form\Field\Part\Hint inputData ( Yiisoft\Form\Field\Base\InputData\InputDataInterface $inputData )
$inputData Yiisoft\Form\Field\Base\InputData\InputDataInterface

                final public function inputData(InputDataInterface $inputData): static
{
    $new = clone $this;
    $new->inputData = $inputData;
    return $new;
}

            
render() public method

public string render ( )

                public function render(): string
{
    $content = $this->content ?? $this->getInputData()->getHint();
    return empty($content)
        ? ''
        : Html::tag($this->tag, $content, $this->attributes)
            ->encode($this->encode)
            ->render();
}

            
tag() public method

Set the container tag name for the hint.

public self tag ( string $tag )
$tag string

Container tag name.

                public function tag(string $tag): self
{
    if ($tag === '') {
        throw new InvalidArgumentException('Tag name cannot be empty.');
    }
    $new = clone $this;
    $new->tag = $tag;
    return $new;
}