backoffice: don't crash previewing fields that fail to render (#46099)

This commit is contained in:
Frédéric Péters 2020-08-25 18:31:38 +02:00
parent b96e2fb4fe
commit 52800f4173
1 changed files with 7 additions and 1 deletions

View File

@ -876,7 +876,13 @@ class FormDefPage(Directory):
for i, field in enumerate(self.formdef.fields):
field.id = i
if hasattr(field, str('add_to_form')):
field.add_to_form(form)
try:
field.add_to_form(form)
except Exception as e:
form.widgets.append(HtmlWidget(htmltext(
'<div class="errornotice"><p>%s (%s)</p></div>') % (
_('Error previewing field.'),
e)))
else:
if field.key == 'page':
if on_page: