Skip to content

Strict types & hidden field #152

Description

@lukascellar
  • bug report? no
  • feature request? yes
  • version: 3.0.0

Description

Currently value of hidden field is always casted to string, even if value is null. I would like to propose to allow null value or cast value to integer/float etc if there are defined validation rules.

forms/src/Forms/Controls/HiddenField.php:

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions