misc: add prefill attributes to widgets in blocks (#45262)
This commit is contained in:
parent
b83e843056
commit
30537f7224
|
@ -8433,6 +8433,32 @@ def test_block_autocomplete_list(pub, blocks_feature):
|
|||
assert '>Bar<' in resp
|
||||
|
||||
|
||||
def test_block_geoloc_prefill(pub, blocks_feature):
|
||||
create_user(pub)
|
||||
FormDef.wipe()
|
||||
BlockDef.wipe()
|
||||
|
||||
block = BlockDef()
|
||||
block.name = 'foobar'
|
||||
block.fields = [
|
||||
fields.StringField(id='123', required=True, label='Test', type='string',
|
||||
prefill={'type': 'geolocation', 'value': 'road'}),
|
||||
]
|
||||
block.store()
|
||||
|
||||
formdef = FormDef()
|
||||
formdef.name = 'form title'
|
||||
formdef.fields = [
|
||||
fields.BlockField(id='1', label='test', type='block:foobar'),
|
||||
]
|
||||
formdef.store()
|
||||
|
||||
app = get_app(pub)
|
||||
resp = app.get(formdef.get_url())
|
||||
assert 'qommon.geolocation.js' in resp
|
||||
assert resp.html.find('div', {'data-geolocation': 'road'})
|
||||
|
||||
|
||||
def test_block_title_and_comment(pub, blocks_feature):
|
||||
create_user(pub)
|
||||
FormDef.wipe()
|
||||
|
|
|
@ -216,6 +216,7 @@ class BlockSubWidget(CompositeWidget):
|
|||
field.add_to_view_form(form=self, value=field_value)
|
||||
else:
|
||||
field.add_to_form(form=self)
|
||||
self.get_widget('f%s' % field.id).prefill_attributes = field.get_prefill_attributes()
|
||||
if value:
|
||||
self.set_value(value)
|
||||
|
||||
|
|
Loading…
Reference in New Issue