On Monday, April 17, 2017 at 1:23:16 PM UTC-7, Dave S wrote:
>
>
>
> On Sunday, April 16, 2017 at 9:11:37 PM UTC-7, Winter Kryz wrote:
>>
>> Thanks, but how can I do the loop thing. I'm new on web2py so I don't 
>> know how to do that.
>>
>> Can you explain me please?
>>
>>
>
> I have a models/mymodel.py that has something like:
>
> db.define_table('mytable',
>                        Field('issueYr','integer', requires=IS_IN_RANGE(
> 1965, 2017)),
>                        otherfields,etc)
>
>
That should be IS_INT_IN_RANGE(1965,2017, "Not a valid year of issue") 

>
>
> and in a controller, I do
>       ....
>       form=SQLFORM('mytable', etc)
>
>
>
> That should do it, although I usually enter a date by hand, and then use 
> browser suggestions.
>

My apologies.  This field does not get a dropdown.

*If *I do 

year_set = set()
for x in range(1965,2017):
   year_set.add(x)


db.define_table('mytable, 
                Field('IssueYr', 'integer', requires=IS_IN_SET(year_set, 
zero=None,
                    error_message="Not a valid year of issue")),
                 [....])


I do get a drop-down, but it's pretty ugly to be recreating the set on 
every call.

(Ugh, I just realized that I'm doing exactly that with some other fields. 
 One of those sets has 50 strings in it.).

(The other observation, from working with credit card forms, is that a 
drop-down with 10-20 entries that all begin with the same substring isn't 
much fun to use.)

/dps

-- 
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