? Failure
Referenced as Related to: # 5277

User tests: Successful: Unsuccessful:

avatar itbra
itbra
14 Oct 2014

I found the form validator to process the passed value only making it hard to implement custom validation rules. I am using form field types that make use of additional data-attributes. These attributes may serve information required to implement a custom validation rule. For instance to validate a date field (filled by a datepicker) the validator not only needs the value, but also a rule (date format) to validate against. This rule may be geographically different and a data-attribute like data-format="YY/MM/DD"may allow to validate the selected date against this rule. When it was possible to pass the element being validated along with the value to be checked the handler may fetch the required date format from the data-format attribute and apply it.
I did not touch the existing handlers' signature since they must not explicitely changed. The passed in element may be accessible via the implicitly accessable arguments object. But, if it is wished to add them a second function parameter for the element i can change it.

This PR implements a very tiny change providing more validation flexibility.

avatar itbra itbra - open - 14 Oct 2014
avatar jissues-bot jissues-bot - change - 14 Oct 2014
Labels Added: ?
avatar nicksavov nicksavov - change - 16 Oct 2014
The description was changed
Labels Added: ?
avatar AnishaVora
AnishaVora - comment - 17 Oct 2014

@test, successful testing.

Tested by creating custom validation handler for the field and validating the field by getting the elements property using the element passed in the handler along with the field value.

I had faced the need to pass the element in the custom validator in following case:
In case of IE 8, place holder attribute is not supported and as an alternative, script needs to be added that will add the place-holder text as value, so in this case, the element passed in the custom validator comes in handy, where we can check if the value of the element is same as the element's placeholder text.

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4672.

avatar AnishaVora AnishaVora - test_item - 17 Oct 2014 - Tested successfully
avatar anibalsanchez
anibalsanchez - comment - 17 Oct 2014

@test, OK. Tested user, module, menu, and article form validations



This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4672.

avatar compojoom compojoom - test_item - 17 Oct 2014 - Tested successfully
avatar yvesh yvesh - test_item - 17 Oct 2014 - Tested successfully
avatar itbra
itbra - comment - 18 Oct 2014

Thank you guys for testing.

I am still thinking about whether to extend the existing handlers' signature and add 'element' as second parameter. This would reflect the capability of handler much better and make accessing that parameter easier as one doesn't need to check the arguments array first for whether that parameter was passed or not. It was therefore fadter an easier accessible.

What do you think?

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4672.

avatar roland-d
roland-d - comment - 27 Nov 2014

@itbra Do you still plan to extend the handlers' signature? Just keep in mind it needs to be backwards compatible.

The PR has some issues too, you probably need to update your PR to the current status of the staging branch.

avatar itbra
itbra - comment - 27 Nov 2014

I don't see any backward compatibility issues since the second parameter Has never been exited before and we are talking about javascript. Not passing it won't cause the handler to fail. Existing handlers have not been changed in the way they validate. They only receive a second argument. Since they appear to not depend on it (yet) they simply don't use it.
However, since programmers might implement custom handlers they might require to have the related target available. This is what t he fix provides. If you see a potential compat. issue just point me and i'll see what i can do.

The issues mentioned appear to not come from my PR. I triple checked the travis build logs and found no error being thrown by my code. If you see more, please just point me to. I'd love to fix it asap as i'd love to see this PR merged soon.

avatar roland-d
roland-d - comment - 1 Dec 2014

@itbra I don't see any issues at this point, just wanted to raise awareness of B/C in case you were going to extend the signature. I do think having the extended signature will be nicer to have.

The travis issues are indeed not yours, let's see when you update the PR what Travis thinks.

I'm afraid i don't know how to do that. Could you tell me please?

How did you create the PR in the first place? If you did it on your local machine in a branch of your own, you could simply update the files and push them again to your branch.

avatar itbra
itbra - comment - 1 Dec 2014

In fact i'm doing all my things online via the github website. I have almost no experience with git - especially with git via commandline and remote repos. Unfortunately i have no also no time to dig into this topic although i require a much better coding workflow including such things.
When i create a PR i go to the joomla-cms repo here on site, navigate to the file i'd like to modify, do my modification and save it, which automatically creates a new branch. That's it. Then, when i require to do some corrections i come back here and apply them.
I guess most of you readers will thinks this is pretty much unhandy and uncomfortable, but its the only way i can provide my help for now.

avatar roland-d
roland-d - comment - 1 Dec 2014

@itbra Nothing unhandy about your workflow if it works for you. It is only troublesome once you need to make changes to files that have been updated in the meantime. What I can do is create a new PR with your changes so it can be merged. Any further changes you want to do, just send them to me and I can update the new PR. Does that help?

If you do not want to update this PR with the extended signature I will make a new PR based on the changes here and we can get that tested. Otherwise you can send me the final changes and I can create the PR based on that.

avatar itbra
itbra - comment - 1 Dec 2014

@roland-d Your offer sounds good to me. Thanks for that! I'd enjoy if you'd to this. The PR is ready to go including the extended signature. After the first successful tests of the initial version arrived i did nothing other than extending the default deployed handlers' signatures adding them the second paramter. So you can take it as is for the new PR.

avatar roland-d
roland-d - comment - 1 Dec 2014

Closing this in favor of #5277.

avatar roland-d roland-d - change - 1 Dec 2014
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2014-12-01 21:49:04
avatar roland-d roland-d - close - 1 Dec 2014

Add a Comment

Login with GitHub to post a comment