You mean something like that ?
def my_validator(form):
   if form.vars['lat'] == '' or form.vars['lng'] == '':
       form.errors['address'] = "address isn't precise enough"


But then wouldn't the form be accepted anyway since onvalidation is called 
when every field passes validation ?


On Wednesday, August 27, 2014 12:08:46 PM UTC+2, Niphlod wrote:
>
> use an onvalidate call that do the checks on lat and lng but adds the 
> error on address.
>
> On Wednesday, August 27, 2014 11:50:42 AM UTC+2, Louis Amon wrote:
>>
>> I'm trying to build a form based on Google Places (geocoding) based on 
>> the following table:
>>
>> db.define_table('place',
>>                 Field('address'),
>>                 Field('street_number'),
>>                 Field('route'),
>>                 Field('locality'),
>>                 Field('lat'),
>>                 Field('lng'),
>>                 )
>>
>> All fields except 'address' are rendered in the form as hidden inputs.
>>
>> I want my form to be validated if and only if 'lat' and 'lng' are not 
>> empty.
>>
>>
>> If I put a validator like IS_FLOAT_IN_RANGE(), these fields are indeed 
>> validated but since they are hidden there is no error message displayed.
>>
>>
>> Is there a way to invalidate 'address' if 'lat' or 'lng' is empty ? If 
>> so, I could then display an error message attached to the input users 
>> actually type into.
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to