Page 1 of 1

Validation doesn't work with updateSelected

PostPosted: Wed Sep 22, 2010 12:58 am
by spintore
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.

Re: Validation doesn't work with updateSelected

PostPosted: Fri Aug 05, 2011 6:59 pm
by Kriss
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

Re: Validation doesn't work with updateSelected

PostPosted: Sat Aug 06, 2011 5:11 pm
by shannah
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

Re: Validation doesn't work with updateSelected

PostPosted: Wed Aug 10, 2011 4:46 am
by spintore
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

Re: Validation doesn't work with updateSelected

PostPosted: Wed Aug 10, 2011 5:08 am
by spintore
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]?(\.[0-9]*)?$/"


I tested it but....it comes with absolutely no warranty.... :D

Ciao

Stefano

Re: Validation doesn't work with updateSelected

PostPosted: Thu Aug 25, 2011 9:11 pm
by Kriss
Thank you Stefano & Steeve for your posts.
Regards