On Wed, Apr 04, 2012 at 05:41:12PM +0200, Damien Baty wrote:
> 
> The current 'deform.widget.SelectWidget' cannot render any <optgroup>
> HTML tag in <select> fields. Has anyone written their own widget that
> offers this? I added this feature in a fork for now
> (https://github.com/dbaty/deform/commit/67c265c560dad23c76a4994610436b0caff784e2)
> but would love to hear about the syntax before I send the pull request,
> if anyone has done something similar. The wording of the documentation
> can also certainly be improved (even though I think the 'deformdemo'
> application -- where I plan to add an example -- will be clearer than
> the API documentation).

Here's my version:

  http://pastebin.com/D9302aYG
  http://pastebin.com/6QpEGnUG

Personally, I think your no_in_optgroup_marker is overly verbose.
In my code, if any item in the values list is a string pair, it is a
plain option, if it is a pair whose second element is a non-string,
then it is an optgroup.

If you do want to be very explicit about which items are option groups
and which are plain options, I'd rather see it the other way around,
with the option groups explicitly marked:

widget = SelectWidget(
    values = [
        ('normal', 'A plain option'),
        OptGroup('Group Label',
                 ('val', 'A grouped option'),
                 ('val2', 'Another grouped option'),
                ),
        ],
    )

If one did the above, then you wouldn't really need the ``optgroup``
option.


Also, for me, (though I would guess not for most others,) it is
important to be able to control the option label and long label
independently.  E.g. I generate something like

  <optgroup label="Foo">
    <option value="foo/bar" label="Bar">Bar (Foo)</option>
  </optgroup>

The short label ("Bar") is displayed by browser which support
<optgroup>, while the long label ("Bar (Foo)") is displayed in
old/bizarre browsers.


Cheers,
Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to