Skip to content

Commit

Permalink
minor fixes to the way null select fields are handled.
Browse files Browse the repository at this point in the history
  • Loading branch information
percious committed Oct 31, 2009
1 parent 71be962 commit ccc28c3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tw2/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def prepare(self):

class RadioButton(InputField):
type = "radio"
checked = twc.Param(attribute=True)
checked = twc.Param(attribute=True, default=False)


class PasswordField(InputField):
Expand Down Expand Up @@ -274,10 +274,13 @@ class SingleSelectField(SelectionField):

def prepare(self):
super(SingleSelectField, self).prepare()
if self.options[0][1] and not self.grouped_options[0][0]:
if len(self.options) > 0 and self.options[0][1] and not self.grouped_options[0][0]:
self.options = [(None, self.null_text)] + self.options
self.grouped_options = [(None, self.options)]

elif self.null_text:
self.options = [(None, self.null_text)] + self.options
self.grouped_options = [(None, self.options)]

class MultipleSelectField(SelectionField):
size = twc.Param('Number of visible options', default=None, attribute=True)
multiple = twc.Param(default=True, attribute=True)
Expand Down

0 comments on commit ccc28c3

Please sign in to comment.