From fc566eea9f986cf7626ac5c394acd6a4684eee97 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Mon, 19 Nov 2018 22:39:13 +0000 Subject: [PATCH] Pass field values through widget.format_value() Fixes #51 This allows the code within Wagtail's Draftail widget that converts the internal HTML format into JSON to run. https://github.com/wagtail/wagtail/blob/72bc5fff6f6d12daf1dc8dc630a3159dafd30e5b/wagtail/admin/rich_text/editors/draftail/__init__.py#L51-L59 --- condensedinlinepanel/edit_handlers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/condensedinlinepanel/edit_handlers.py b/condensedinlinepanel/edit_handlers.py index 0215bf8..35d4e9c 100644 --- a/condensedinlinepanel/edit_handlers.py +++ b/condensedinlinepanel/edit_handlers.py @@ -140,7 +140,7 @@ def get_form_extra_data(form): 'id': i, 'instanceAsStr': six.text_type(form.instance), 'fields': { - field_name: form[field_name].value() + field_name: form[field_name].field.widget.format_value(form[field_name].value()) for field_name in form.fields.keys() }, 'extra': get_form_extra_data(form), @@ -156,7 +156,7 @@ def get_form_extra_data(form): ], 'emptyForm': { 'fields': { - field_name: self.empty_form[field_name].value() + field_name: self.empty_form[field_name].field.widget.format_value(self.empty_form[field_name].value()) for field_name in self.empty_form.fields.keys() } }