Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict types & hidden field #152

lukascellar opened this issue Apr 19, 2017 · 2 comments

Strict types & hidden field #152

lukascellar opened this issue Apr 19, 2017 · 2 comments


Copy link

@lukascellar lukascellar commented Apr 19, 2017

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


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.


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;
Copy link

@dg dg commented Apr 23, 2017

What about addRule(Form::INTEGER) on hidden field?

Copy link

@lukascellar lukascellar commented Apr 23, 2017

Works addRule(Form::INTEGER) with hidden input in 2.4? Tried it now, but in onSuccess callback value of id is still a string.

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

No branches or pull requests

2 participants