forms: add list-add class to "add item" widget (#45688)
This commit is contained in:
parent
4ca1fe7834
commit
aa0aacfb04
|
@ -8655,6 +8655,7 @@ def test_block_repeated(pub, blocks_feature):
|
||||||
assert resp.text.count('>Test<') == 1
|
assert resp.text.count('>Test<') == 1
|
||||||
assert resp.text.count('>hintblock<') == 1
|
assert resp.text.count('>hintblock<') == 1
|
||||||
assert 'Add another' in resp
|
assert 'Add another' in resp
|
||||||
|
assert resp.html.find('div', {'class': 'list-add'})
|
||||||
resp = resp.form.submit('f1$add_element')
|
resp = resp.form.submit('f1$add_element')
|
||||||
assert resp.text.count('>Test<') == 2
|
assert resp.text.count('>Test<') == 2
|
||||||
assert resp.text.count('>hintblock<') == 1
|
assert resp.text.count('>hintblock<') == 1
|
||||||
|
|
|
@ -237,6 +237,10 @@ TextWidget.render_content = text_render_content
|
||||||
|
|
||||||
|
|
||||||
class SubmitWidget(quixote.form.widget.SubmitWidget):
|
class SubmitWidget(quixote.form.widget.SubmitWidget):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.extra_css_class = kwargs.pop('extra_css_class', None)
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def render_content(self):
|
def render_content(self):
|
||||||
if self.name in ('cancel', 'previous', 'save-draft'):
|
if self.name in ('cancel', 'previous', 'save-draft'):
|
||||||
self.attrs['formnovalidate'] = 'formnovalidate'
|
self.attrs['formnovalidate'] = 'formnovalidate'
|
||||||
|
@ -387,7 +391,7 @@ class Form(QuixoteForm):
|
||||||
r = TemplateIO(html=True)
|
r = TemplateIO(html=True)
|
||||||
classnames = '%s widget %s-button %s' % (
|
classnames = '%s widget %s-button %s' % (
|
||||||
button.__class__.__name__, button.name,
|
button.__class__.__name__, button.name,
|
||||||
getattr(button, 'extra_css_class', ''))
|
getattr(button, 'extra_css_class', None) or '')
|
||||||
r += htmltext('<div class="%s">') % classnames
|
r += htmltext('<div class="%s">') % classnames
|
||||||
r += htmltext('<div class="content">')
|
r += htmltext('<div class="content">')
|
||||||
r += button.render_content()
|
r += button.render_content()
|
||||||
|
|
Loading…
Reference in New Issue