Skip to content

Commit 4076338

Browse files
committed
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.
1 parent 7a5587c commit 4076338

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

roundup/cgi/templating.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,12 @@ def classhelp(self, properties=None, label=''"(list)", width='500',
762762
(help_url, onclick, cgi_escape_attrs(**html_kwargs),
763763
self._(label))
764764

765-
def submit(self, label=''"Submit New Entry", action="new"):
765+
def submit(self, label=''"Submit New Entry", action="new", html_kwargs={}):
766766
""" Generate a submit button (and action hidden element)
767767
768+
"html_kwargs" specified additional html args for the
769+
generated html <select>
770+
768771
Generate nothing if we're not editable.
769772
"""
770773
if not self.is_edit_ok():
@@ -775,7 +778,8 @@ def submit(self, label=''"Submit New Entry", action="new"):
775778
'\n' + \
776779
self.input(type="hidden", name="@action", value=action) + \
777780
'\n' + \
778-
self.input(type="submit", name="submit_button", value=self._(label))
781+
self.input(type="submit", name="submit_button", value=self._(label),
782+
**html_kwargs)
779783

780784
def history(self):
781785
if not self.is_view_ok():
@@ -905,9 +909,12 @@ def is_retired(self):
905909
"""Is this item retired?"""
906910
return self._klass.is_retired(self._nodeid)
907911

908-
def submit(self, label=''"Submit Changes", action="edit"):
912+
def submit(self, label=''"Submit Changes", action="edit", html_kwargs={}):
909913
"""Generate a submit button.
910914
915+
"html_kwargs" specified additional html args for the
916+
generated html <select>
917+
911918
Also sneak in the lastactivity and action hidden elements.
912919
"""
913920
return self.input(type="hidden", name="@lastactivity",
@@ -919,7 +926,7 @@ def submit(self, label=''"Submit Changes", action="edit"):
919926
self.input(type="hidden", name="@action", value=action) + \
920927
'\n' + \
921928
self.input(type="submit", name="submit_button",
922-
value=self._(label))
929+
value=self._(label), **html_kwargs)
923930

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

0 commit comments

Comments
 (0)