def getyears(anyo): 
    from datetime import datetime, date
    option = []
    option.append(OPTION(T('Año'), _value=''))
    year = datetime.today().year
    ryear = range(2015, int(year+1))
    for r in ryear:
        if anyo == r:
            selected = True
        else:
            selected = None
        option.append(OPTION(r, _value=r, _selected=selected))
    return SELECT(*option, _name='anyo', _id='anyo', _class="form-control 
input-md")


El domingo, 16 de abril de 2017, 23:07:08 (UTC+2), Winter Kryz escribió:
>
> Hello everybody,
>
> I have a table like this
>
> db.define_table('Report',
>                 Field('person', 'reference Person'),
>                 Field('year', 'integer'),
>                 Field('letter', 'string'),
>                )
>
> and I use SQLFORM to create a form with that table
>
> form=SQLFORM(db.Report)
>
> I want to know if instead a 'year' field where I have to write the year, I 
> can fill a select with years from 1989 to 2017 so the user can pick one 
> from that list. I don't know how to do that because I'm using a sqlform. 
>
> Any ideas would be appreciate.
>
> Thanks!
>
>
>

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