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 Yiisoft\Form\Field\Base\InputData\InputDataInterface getInputData ( )

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

            
getName() protected method

protected string|null getName ( )

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

            
getValue() protected method

protected mixed getValue ( )

                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 Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait 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;
    $new->useCustomName = false;
    $new->useCustomValue = false;
    return $new;
}

            
name() public method

public Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait name ( string|null $name )
$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 Yiisoft\Form\Field\Base\InputData\InputDataWithCustomNameAndValueTrait prepareValue ( callable|null $callback )
$callback callable|null

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

            
value() public method

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

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