Welcome Guest, Not a member yet? Register   Sign In
Form validation callables combined with "required"
#11

(02-09-2016, 12:44 PM)Narf Wrote:
(02-09-2016, 10:08 AM)skunkbad Wrote:
(02-09-2016, 02:26 AM)Narf Wrote: Well, it's rare that someone doesn't use 'required' AND uses a callback at the same time, but this has been reported as a bug quite a few times.

I'm thinking of changing it in 3.1.

I'm not calling it a bug, and I do see how mwhitney's comment about a "conditionally required" field would present a legitimate reason to keep things as is. A simple note in the docs would be nice.

I know you're not calling it a bug (and it's not), but others have ... mwhitney's comment is pretty much the reasoning used behind closing such reports as invalid. Yet, it's obvious that this reasoning is obvious to nobody (myself included), hence why I'm thinking of changing it.

If you change it, what do you propose is a solution to the scenario that mwhitney presents? Maybe a new "not_required" rule?
Reply
#12

Not sure yet, but I don't really like the "not_required" idea.
Reply
#13

(This post was last modified: 02-09-2016, 04:39 PM by RobertSF.)

I had not expected the absence of "required" to end validation and call it successful. After all, in addition to mwhitney's scenario, there might be a field that is not required, but if supplied, must be numeric. But I guess that's precisely why callbacks are executed when there is no "required" rule. Callbacks are for those cases that don't conform to "regular" form validation.

I think the solution that would require the least change and provide the most benefit would be skunkbad's suggestion to make a note of the issue in the documentation. It truly is not a bug but a feature!
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
Reply
#14

(02-09-2016, 03:59 PM)RobertSF Wrote: I had not expected the absence of "required" to end validation and call it successful. After all, in addition to mwhitney's scenario, there might be a field that is not required, but if supplied, must be numeric.

Validation succeeds only if the field is empty, it doesn't blindly trust fields without the "required" rule.
Reply
#15

(02-09-2016, 10:16 PM)Narf Wrote:
(02-09-2016, 03:59 PM)RobertSF Wrote: I had not expected the absence of "required" to end validation and call it successful. After all, in addition to mwhitney's scenario, there might be a field that is not required, but if supplied, must be numeric.

Validation succeeds only if the field is empty, it doesn't blindly trust fields without the "required" rule.

A "required_if" rule might be useful for mwhitney's scenario. I could use one right now as I'm having trouble associating a rule name with a callable rule.

If a rule name is supplied (per the third example in "Use anything as a rule") and the field is blank the validation does not run. If I don't supply the rule name it runs but the error message is not found and it returns "Unable to access an error message corresponding to blah, blah, blah..."
Reply




Theme © iAndrew 2016 - Forum software by © MyBB