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

Form: addRule (regex) is not validating after addFilter #268

Closed
wants to merge 1 commit into from
Closed

Form: addRule (regex) is not validating after addFilter #268

wants to merge 1 commit into from

Conversation

solcik
Copy link
Contributor

@solcik solcik commented Feb 9, 2021

  • bug fix
  • BC break? no
  • doc PR:

Hello David @dg,

https://github.com/nette/docs/blob/doc-3.1/cs/form-validation.texy#L179-L192

When I tried addFilter as mentioned in docs, it does transform the value, but the validator after that does not validate.
Here is a failing test for that use-case.

I think that problem is here somewhere about here.

https://github.com/nette/forms/blob/master/src/Forms/Controls/TextInput.php#L72-L73

I am not sure, how to fix that, so I do not break anything else.

Thank you very much in advance.

@dg dg closed this in c8b7f41 Feb 10, 2021
@dg
Copy link
Member

dg commented Feb 10, 2021

Thanks for tests!

dg added a commit that referenced this pull request Feb 10, 2021
dg added a commit that referenced this pull request Feb 10, 2021
dg added a commit that referenced this pull request Feb 11, 2021
@Daaarkling
Copy link
Contributor

Hi @dg. I'm still having some trouble with this. Rules are not generated into html. I'm on current version 3.1.2

$form = new Form();

// nope
$form->addText('test')
	->addFilter(fn ($value) => $value)
	->addRule(Form::FLOAT);

// ok
$form->addText('test2')
	->addRule(Form::FLOAT)
	->addFilter(fn ($value) => $value);

return $form;
{control form}
<input type="text" name="test" id="frm-testForm-test" class="text">
<input type="text" name="test2" id="frm-testForm-test2" data-nette-rules="[{&quot;op&quot;:&quot;:float&quot;,&quot;msg&quot;:&quot;Please enter a valid number.&quot;}]" class="text">

Could you pls double check that fix. Thank you 🤗

@janpecha
Copy link

@Daaarkling IMHO it's correct behavior, see #259

@solcik solcik deleted the test-1 branch February 11, 2021 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants