Skip to content

Commit

Permalink
Add the ability to suppress question labels on form widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
lfdebrux committed Jul 11, 2018
1 parent 0176024 commit 6360b10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dmutils/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


class DMBooleanField(DMFieldMixin, wtforms.fields.BooleanField):
widget = DMCheckboxInput()
widget = DMCheckboxInput(hide_question=True)

type = "checkbox"

Expand Down
9 changes: 6 additions & 3 deletions dmutils/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ class DMJinjaWidgetBase:

template_args = []

def __init__(self):
def __init__(self, hide_question=False):
# we include common template arguments here to avoid repetition
self.template_args = ["error", "name", "hint", "question", "value"] + self.template_args
if hide_question:
self.template_args.remove("question")

self.template = None

def __call__(self, field, **kwargs):
Expand All @@ -32,8 +35,8 @@ class DMSelectionButtonBase(DMJinjaWidgetBase):
template_args = ["type", "inline", "options"]
template_file = "toolkit/forms/selection-buttons.html"

def __init__(self):
super().__init__()
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.template_args.remove("value")

def __call__(self, field, **kwargs):
Expand Down

0 comments on commit 6360b10

Please sign in to comment.