Validation doesn't work with updateSelected

A place for users and developers of the Xataface to discuss and receive support.

Validation doesn't work with updateSelected

Postby 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.
spintore
 
Posts: 3
Joined: Fri Sep 17, 2010 4:10 am

Re: Validation doesn't work with updateSelected

Postby 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
Kriss
 
Posts: 5
Joined: Fri Aug 05, 2011 6:29 pm

Re: Validation doesn't work with updateSelected

Postby 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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Validation doesn't work with updateSelected

Postby 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
Last edited by spintore on Wed Aug 10, 2011 5:15 am, edited 2 times in total.
spintore
 
Posts: 3
Joined: Fri Sep 17, 2010 4:10 am

Re: Validation doesn't work with updateSelected

Postby 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]?(\.[0-9]*)?$/"


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

Ciao

Stefano
spintore
 
Posts: 3
Joined: Fri Sep 17, 2010 4:10 am

Re: Validation doesn't work with updateSelected

Postby Kriss » Thu Aug 25, 2011 9:11 pm

Thank you Stefano & Steeve for your posts.
Regards
Kriss
 
Posts: 5
Joined: Fri Aug 05, 2011 6:29 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 20 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved