We need to be able to disable choices in a <select>, which is done by setting the disabled attribute on the <option> tag, for example: <option value="bananas" disabled="disabled">Bananas</option>
Currently we're doing this by subclassing the Select widget: http://djangosnippets.org/snippets/2453/ It would be nice if the built in Select widget supported this. One way would be to replace the existing render_option method with what I've written, and I can prepare a patch if desired, but this approach changes the format of the "choices" data structure to something that won't be understood by other widgets. Perhaps these widgets should be improved too, but I don't want to do this unless my changes have a good chance of being accepted. I logged this as a ticket (16149) and was told to discuss it here. To address aagustin's comments: 1. Backwards compatibility is already addressed. If the widget is passed a regular "choices" field, the existing behavior is preserved. 2. I don't understand what you mean by "boilerplate" in the API. A "choices" field with a disabled choice looks like: choices = (('apples', 'Apples'), ('oranges', 'Oranges'), ('bananas', {'label': 'Bananas', 'disabled': True}), ('grobblefruit', 'Grobblefruit')) I can't think of a more concise way of clearly representing that 'bananas' is disabled while still allowing it to have a label, unless we want to change the "choices" data structure a lot more to something like: choices = (('apples', 'Apples'), ('oranges', 'Oranges'), ('bananas', 'Bananas', {'disabled': True}), ('grobblefruit', 'Grobblefruit')) Suggestions & other thoughts welcome :) Jody -- 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 django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.