google-code-export / dojango

Automatically exported from code.google.com/p/dojango
Other
1 stars 0 forks source link

Feature request: Allow ComboBox to re-display manually entered values #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a ComboBox with some pre-defined choices
2. In the resulting webpage enter something not in those choices
3. If the field is redisplayet, the manually entered value is not in the list 
of choices, and will hence not be shown to the user (even though it was 
accepted when he entered it)

Possible implementation:

Override the render_options-method in the ComboBox widget:

    def render_options(self, choices, selected_choices):
        display_choices = [ (choice, choice) for choice in selected_choices 
                                            if choice and not choice in [ given_choice[0] for given_choice in chain(self.choices, choices) ] 
                            ] + list(choices)
        return super(ComboBox, self).render_options(display_choices, selected_choices)

This works for me.

Original issue reported on code.google.com by soeren.h...@gmail.com on 11 Jan 2011 at 10:35

GoogleCodeExporter commented 9 years ago
Same as issue #64. Please use FilteringSelect instead or if you would like to 
be able to add new choices (that or not in the previous list of choices)  you 
should write your custom widget and attach the mentioned logic to that.

Original comment by tobias.k...@googlemail.com on 7 Feb 2011 at 11:26