0 follower

Trait Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait

Implemented byYiisoft\Form\Field\Base\DateTimeInputField, Yiisoft\Form\Field\Base\InputField, Yiisoft\Form\Field\Checkbox, Yiisoft\Form\Field\CheckboxList, Yiisoft\Form\Field\Color, Yiisoft\Form\Field\Date, Yiisoft\Form\Field\DateTimeLocal, Yiisoft\Form\Field\Email, Yiisoft\Form\Field\File, Yiisoft\Form\Field\Hidden, Yiisoft\Form\Field\Number, Yiisoft\Form\Field\Password, Yiisoft\Form\Field\RadioList, Yiisoft\Form\Field\Range, Yiisoft\Form\Field\Select, Yiisoft\Form\Field\Telephone, Yiisoft\Form\Field\Text, Yiisoft\Form\Field\Textarea, Yiisoft\Form\Field\Time, Yiisoft\Form\Field\Url

Psalm Types

Name Value
PrepareValueCallback callable

Method Details

Hide inherited methods

getInputData() protected method

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

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

            
getName() protected method

protected getName( ): string|null

                final protected function getName(): ?string
{
    return $this->useCustomName
        ? $this->customName
        : $this->getInputData()->getName();
}

            
getValue() protected method

protected getValue( ): mixed

                final protected function getValue(): mixed
{
    $value = $this->useCustomValue
        ? $this->customValue
        : $this->getInputData()->getValue();
    return $this->prepareValueCallback === null
        ? $value
        : ($this->prepareValueCallback)($value);
}

            
inputData() public method

public inputData( Yiisoft\Form\Field\Base\InputData\InputDataInterface $inputData ): Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait
$inputData Yiisoft\Form\Field\Base\InputData\InputDataInterface

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

            
name() public method

public name( string|null $name ): Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait
$name string|null

                final public function name(?string $name): static
{
    $new = clone $this;
    $new->customName = $name;
    $new->useCustomName = true;
    return $new;
}

            
prepareValue() public method

public prepareValue( callable|null $callback ): Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait
$callback callable|null

                final public function prepareValue(?callable $callback): static
{
    $new = clone $this;
    $new->prepareValueCallback = $callback;
    return $new;
}

            
value() public method

public value( mixed $value ): Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait
$value mixed

                final public function value(mixed $value): static
{
    $new = clone $this;
    $new->customValue = $value;
    $new->useCustomValue = true;
    return $new;
}