On 1/7/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi all,

the select-form-widget and the selectmultiple-form-widget display's a 
choices-list as

<select ...>
  <option>...
  ...
</select>

From the per-row-level-permision branch there is an alternative issue to do 
something like this:

<select ...>
  <optgroup label="...">
    <option>...
  </optgroup>
  ...
</select>

I made 2 new widgets, selectgrouped and selectmultiplegrouped, which would 
resolve such an issue. The optgroup is inserted into choices like a normal 
option: choices= ( ['__group__', 'label for group'], ['value1', 'label1'])

I added a simple example into the regression tests.

I would be also possible to merge the select/selectgrouped widget into one 
widget, which I would prefer to be the best solution.

in this case you would have to add a custom validation saying that
__group__ is not allowed, even though it's listed in choices...

would it be acceptible to have different 'choices' layout? for example:

choices =(
...   ( 'Group_name1', [(1, 'one'), (2,'two'), ]),
...   ( 'Group_name2', [(3, 'three'), (2,'four'), ]),
... )
# simpler render method
output = '<select name="">\n  %s\n</select>' % '\n  '.join( [
...   '<optgroup label="%s">\n    %s\n  </optgroup>' %
...     ( gr_label, '\n    '.join( [
...             u'<option value="%s"%s>%s</option>' % ( value, (value
== 'two' and ' selected="selected" ' or ''), label ) for label, value
in gr_list
...         ] ) ) for gr_label, gr_list in choices
... ] )

print output
<selectname="">
 <optgroup label="Group_name1">
   <option value="one">1</option>
   <option value="two" selected="selected" >2</option>
 </optgroup>
 <optgroup label="Group_name2">
   <option value="three">3</option>
   <option value="four">2</option>
 </optgroup>
</select>

this would mean incopatibility with Select and SelectMultiple, but on
the other hand no special magic like '__group__'

I do not feel strongly one way or the other, just offering another option...


Regards,
Dirk
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal f r Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

>





--
Honza Kr l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to