Feb 26, 2010, 1:08 PM
[0.8.2] "Validator" property vs. AllowBlank
I'm not sure this is really a bug, and not just intended behavior, but I encountered this while trying to set up some custom validators.
If you have a blank value in a textfield, the only property it checks is allowBlank. The validation function will return at that point, either true if allowBlank is true, or false (with appropriate error) if not.
Unfortunately this makes it impossible to define a Validator (using the validator property on Field) to validate blank values.
In my application, this was needed because I did not want to allow blank values in certain fields if a checkbox elsewhere was checked (standard "is this address same as that other address" scenario).
Please note that I /did/ find a workaround by writing a js function on my checkbox that set/unset allowBlank on each control in my secondary address block, but that isn't the ideal scenario I'd wanted.
If you have a blank value in a textfield, the only property it checks is allowBlank. The validation function will return at that point, either true if allowBlank is true, or false (with appropriate error) if not.
Unfortunately this makes it impossible to define a Validator (using the validator property on Field) to validate blank values.
In my application, this was needed because I did not want to allow blank values in certain fields if a checkbox elsewhere was checked (standard "is this address same as that other address" scenario).
Please note that I /did/ find a workaround by writing a js function on my checkbox that set/unset allowBlank on each control in my secondary address block, but that isn't the ideal scenario I'd wanted.