我想将css类allowMultiSubmit
添加到zrc.form按钮以避免多次提交警报。按钮的定义如下:
from z3c.form import form
from plone.app.z3cform.layout import wrap_form
class MyForm(form.Form):
...
@button.buttonAndHandler(_(u"Search"))
def handleSearch(self, action):
...
MyWrappedFormView = wrap_form(MyForm)
我想要达到的结果是:
<input id="form-buttons-search"
class="submit-widget button-field allowMultiSubmit"
type="submit"
value="Search"
name="form.buttons.search">
必须是一种简单的方法,但我无法弄清楚如何。
答案 0 :(得分:9)
您可以覆盖z3c.form类的updateActions方法,并使用addClass方法将css类添加到按钮中:
from z3c.form import form
from plone.app.z3cform.layout import wrap_form
class MyForm(form.Form):
...
@button.buttonAndHandler(_(u"Search"))
def handleSearch(self, action):
...
def updateActions(self):
super(MyForm, self).updateActions()
self.actions['submit'].addClass("allowMultiSubmit")
MyWrappedFormView = wrap_form(MyForm)