I read this post
http://groups.google.com/group/web2py/browse_thread/thread/f9967ef7151c5ae8/d0c47ff7a40e0dfc?lnk=gst&q=OPTGROUP#d0c47ff7a40e0dfc
and I didn't find optgroup in html.py either
so why not adding it since from time to time people may need it?
Use TAG.optgroup
On Feb 15, 3:19 am, "hamdy.a.farag" <hamdy.a.fa...@inbox.com> wrote:
> Hi
>
> I read this post
> http://groups.google.com/group/web2py/browse_thread/thread/f9967ef715...
Here is a little example:
def index():
OG=TAG.OPTGROUP
g1=[ OPTION( r.name, _value=r.id ) for r in
db(db.person.age<=30).select() ]
g2=[ OPTION( r.name, _value=r.id ) for r in
db(db.person.age>30).select() ]
ogs=[OG(_label='30 and under',*g1),OG(_label='over 30',*g2)]
sel=SELECT(_name='person',*ogs )
f=FORM( sel )
print ogs[0] # OK
print ogs[1] # OK
print sel # not OK
return dict(f=f)
The SELECT is completely messed up inside since it only checks for
OPTION instances.
Denes.
On 15 feb, 09:48, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Please let' snot proliferate these.
>
> Use TAG.optgroup
>
> On Feb 15, 3:19 am, "hamdy.a.farag" <hamdy.a.fa...@inbox.com> wrote:
>
> > Hi
>
> > I read this post
> > http://groups.google.com/group/web2py/browse_thread/thread/f9967ef715...
>
> > and I didn't findoptgroupin html.py either
you can create OPTGROUPs with TAG.OPTGROUP
but do NOT use it with the SELECT helper,
you must use TAG.SELECT as in the following example:
def index():
OG=TAG.OPTGROUP
g1=[ OPTION( r.name, _value=r.id ) for r in
db(db.person.age<=30).select() ]
g2=[ OPTION( r.name, _value=r.id ) for r in
db(db.person.age>30).select() ]
ogs=[OG(_label='30 and under',*g1),OG(_label='over 30',*g2)]
sel = TAG.SELECT(_name='person', *ogs)
# DO NOT USE sel=SELECT(_name='person',*ogs )
f=FORM( sel )
return dict(f=f)
Denes.
selectnombre = SELECT(OPTGROUP(*opcions, _label="grupo"), _name="selNombre", _id="selNombre",
_multiple="multiple")
Saludos!!