Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add html_kwargs to submit button
now submit buttons can have individual attributes as well. Useful for
the bootstrap style where submit buttons require a class to look nice.
  • Loading branch information
aparcar committed Dec 2, 2018
commit 407633818131f7e5af4572ad20b006c60814dca3
15 changes: 11 additions & 4 deletions roundup/cgi/templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,12 @@ def classhelp(self, properties=None, label=''"(list)", width='500',
(help_url, onclick, cgi_escape_attrs(**html_kwargs),
self._(label))

def submit(self, label=''"Submit New Entry", action="new"):
def submit(self, label=''"Submit New Entry", action="new", html_kwargs={}):
""" Generate a submit button (and action hidden element)

"html_kwargs" specified additional html args for the
generated html <select>

Generate nothing if we're not editable.
"""
if not self.is_edit_ok():
Expand All @@ -775,7 +778,8 @@ def submit(self, label=''"Submit New Entry", action="new"):
'\n' + \
self.input(type="hidden", name="@action", value=action) + \
'\n' + \
self.input(type="submit", name="submit_button", value=self._(label))
self.input(type="submit", name="submit_button", value=self._(label),
**html_kwargs)

def history(self):
if not self.is_view_ok():
Expand Down Expand Up @@ -905,9 +909,12 @@ def is_retired(self):
"""Is this item retired?"""
return self._klass.is_retired(self._nodeid)

def submit(self, label=''"Submit Changes", action="edit"):
def submit(self, label=''"Submit Changes", action="edit", html_kwargs={}):
"""Generate a submit button.

"html_kwargs" specified additional html args for the
generated html <select>

Also sneak in the lastactivity and action hidden elements.
"""
return self.input(type="hidden", name="@lastactivity",
Expand All @@ -919,7 +926,7 @@ def submit(self, label=''"Submit Changes", action="edit"):
self.input(type="hidden", name="@action", value=action) + \
'\n' + \
self.input(type="submit", name="submit_button",
value=self._(label))
value=self._(label), **html_kwargs)

def journal(self, direction='descending'):
""" Return a list of HTMLJournalEntry instances.
Expand Down