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

Forms: validation serverSide & clientSide #1294

Open
hrach opened this issue Dec 10, 2013 · 6 comments
Open

Forms: validation serverSide & clientSide #1294

hrach opened this issue Dec 10, 2013 · 6 comments

Comments

@hrach
Copy link
Contributor

hrach commented Dec 10, 2013

In current implementation it's (almost) impossible to add validation, which would generate some validation name for client-side. Let's take a walk.

  1. Only way to let Nette Forms generate some client-side validation name is to pass string callback, or some other structure, which is static. Defined here. This means that these examples are only acceptable
    • fnValidator
    • foo\fnValidator -> string -> the name is not "corrected" for js
    • foo\bar::methodValidator -> string -> the name is not "corrected" for js
    • array('MyClass, 'methodValidator')
  2. But it is impossible to pass these callback as a validator for Rule.
    • only way is to use NOT-namespace function
    • namespaced function correctly pass this check, however, js fn name is unusable "op":"foo\\mytest".
    • static call doesn't pass through is_callable function here - to be correct, it doesn't pass in array format. In string format such as foo::mytest this function behaves ok... but there is again problem with unusable javascript name ("op":"foo\bar::mytest")

I would like to see some option to name the validation for Javascript.

@dg
Copy link
Member

dg commented Dec 10, 2013

@hrach
Copy link
Contributor Author

hrach commented Dec 10, 2013

How can I missed that? :D

This make it a little bit easier, but I would like to use some non-static callback, couldn't be here implemented something like

if (is_array($op)) {
    $op = get_class($op[0]) . '::' . $op[1]);
}

Otherwise I would close this.

@dg
Copy link
Member

dg commented Dec 10, 2013

I have some plans to improve validation and this will be solved.

@Majkl578
Copy link
Contributor

Unfortunately, that still doesn't solve problem with closures (which are most handful) at all.

@hrach
Copy link
Contributor Author

hrach commented Dec 10, 2013

@Majk578 ... yes.

@Majkl578
Copy link
Contributor

I'm thinking about automated identifying closures and only possible cross-request solution seems to be declaring filename + line, but that won't work in oneliners. :S Any other idea?

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

No branches or pull requests

3 participants