Validation doesn’t work with updateSelected
Archived from the Xataface Users forum.
spintore — Wed Sep 22, 2010 12:58 am
Dear all, I’m trying to validate a field in my first Xataface 1.2.5 project.
I wrote a latitude__validate function and a validators:regex for the latitude field in the fields.ini file for my table.
They works correctly when I edit the records, I tested them disabling or enabling javascript in the browser.
But when I use the updateSelected button on a list of records the validation is not applied and unmatched values are saved in the database.
This happens either using the regex or the latitude__validate function alone, and using the two methods together.
Is this the expected behavior or am I missing something and the validation could be applied with the updateSelected too?
Any help would be greatly appreciated.
Kriss — Fri Aug 05, 2011 6:59 pm
Hi,
I can’t help you as i’m a newbie in Xataface and Php.
But i’m looking for a regex expression to validate latitude and longitude fields.
Could you tell me the expression you wrote ?
Thanks
shannah — Sat Aug 06, 2011 5:11 pm
Currently the __validate() methods aren’t used by the update/copy form - only the new/edit forms. You may want to move your validation into the beforeSave() delegate class method. There is an example on this page:
http://xataface.com/documentation/tutor … d/triggers
(Under the heading “handling errors”)
Steve
spintore — Wed Aug 10, 2011 4:46 am
shannah wrote:Currently the __validate() methods aren’t used by the update/copy form - only the new/edit forms. You may want to move your validation into the beforeSave() delegate class method. There is an example on this page:
http://xataface.com/documentation/tutor … d/triggers
(Under the heading “handling errors”)Steve
Thank you shannah for your reply, I will test your solution soon.
Stefano
spintore — Wed Aug 10, 2011 5:08 am
Kriss wrote:Hi,
I can’t help you as i’m a newbie in Xataface and Php.
But i’m looking for a regex expression to validate latitude and longitude fields.
Could you tell me the expression you wrote ?
Thanks
Dear Kriss, this is a piece of my fields.ini file with the latitude and longitude regexp
They should match
-90.0 <= latitude <= +90.0
-180.0 <= longitude <=+180.0
Values are decimal degrees.
[latitude]
widget:label = “Latitude”
validators:required = true
validators:regex = “/^-?[0-8]?[0-9]?(.[0-9]*)?$|^-?90(.0*)?$/”
[longitude]
widget:label = “Longitude”
validators:required = true
validators:regex = “/^-?180(.0*)?$|^-?1[0-7]0-9?$|^-?[0-9]?[0-9]?(.[0-9]*)?$/”
I tested it but….it comes with absolutely no warranty….
Ciao
Stefano
Kriss — Thu Aug 25, 2011 9:11 pm
Thank you Stefano & Steeve for your posts.
Regards