Nette\Forms\Controls\TextBase::setValue PHP Method

setValue() public method

Sets control's value.
public setValue ( $value ) : self
return self
    public function setValue($value)
    {
        if ($value === NULL) {
            $value = '';
        } elseif (!is_scalar($value) && !method_exists($value, '__toString')) {
            throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or NULL, %s given in field '%s'.", gettype($value), $this->name));
        }
        $this->rawValue = $this->value = $value;
        return $this;
    }

Usage Example

Beispiel #1
0
 /**
  * @param  DateTime|string|NULL  $value
  * @return static
  */
 public function setValue($value = NULL)
 {
     if ($value instanceof \DateTime) {
         $value = $value->format($this->format);
     }
     return parent::setValue($value);
 }
All Usage Examples Of Nette\Forms\Controls\TextBase::setValue