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

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 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 static 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 static name ( ?string $name )
$name ?string

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

            
prepareValue() public method

public static prepareValue ( ?callable $callback )
$callback ?callable

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

            
value() public method

public static value ( mixed $value )
$value mixed

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