Got it, thanks!
On Nov 19, 12:57 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> two ways
>
> SELECT(OPTION('one',_value=1),OPTION('two',_value=2),value=1)
>
> or
>
> SELECT(OPTION('one',_value=1,_selected=True),OPTION('two',_value=2))
>
> On Nov 19, 11:29 am, Dmitri Zagidulin <dzagidu...@gmail.com> wrote:
>
> > Sure. And the other question, the specifying which option you want
> > 'selected', in the SELECT constructor?
>
> > On Nov 19, 12:13 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > You can do something like
>
> > > d={1:'one', 2:'two'}
> > > SELECT(*[OPTION(v,_value=k) for (k,v) in d.items()])
>
> > > and variations
>
> > > On Nov 19, 10:51 am, Dmitri Zagidulin <dzagidu...@gmail.com> wrote:
>
> > > > Ok, that makes sense, that's how I ended up doing it. I was just
> > > > wondering if there was a short form, like with the list of strings (as
> > > > opposed to a list of OPTION objects), but with tuples.
>
> > > > Oh! One other question. Is there a way (or would you accept a patch)
> > > > to specify which value you want selected, when creating a SELECT
> > > > helper? There's a 'value=' parameter to the constructor, but that
> > > > seems to refer to the contents of the option, not its value (so, you
> > > > can do value='one' but not value='1', from the example below).
>
> > > > On Nov 19, 11:45 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > yes,
>
> > > > > SELECT(OPTION('one',_value=1),OPTION('two',_value=2))
>
> > > > > On Nov 19, 9:54 am, Dmitri Zagidulin <dzagidu...@gmail.com> wrote:
>
> > > > > > When you pass a list of strings to the SELECT helper, it creates an
> > > > > > html select control, with options populated from the list of
> > > > > > strings,
> > > > > > and each string is both the option's value and label.
>
> > > > > > so, SELECT(['one, 'two']) yields
> > > > > > <select>
> > > > > > <option value="one">one</option>
> > > > > > etc.
>
> > > > > > Does SELECT provide for the other common usage scenario, where
> > > > > > you're
> > > > > > trying to create a list of options that have, say, an integer id as
> > > > > > the value and a string label as the contents of the option?
> > > > > > (That is, something like SELECT([ ('1', 'one'), ('2', 'two')])
> > > > > > yielding:
> > > > > > <select>
> > > > > > <option value="1">one</option> .. etc.
> > > > > > )
> > > > > > So, is it possible to pass in a list of tuples to SELECT (instead of
> > > > > > just a flat list)?
>
> > > > > > If not, would you accept a patch to make that possible?
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to
web2py+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---