Aram Dulyan committed e865554

Added hidden widget overriding for MarkupFields.
The hidden widget now correctly uses the raw, rather than rendered, value. This fixes issues when a MarkupField has a callable default (which triggers hidden widget rendering), resulting in unescaped HTML characters in the <input> value.

  • Participants
  • Parent commits 9f7c4de

Comments (0)

Files changed (2)

File markitup/

     def formfield(self, **kwargs):
         defaults = {'widget': widgets.MarkupTextarea}
-        return super(MarkupField, self).formfield(**defaults)
+        field = super(MarkupField, self).formfield(**defaults)
+        field.hidden_widget = widgets.MarkupHiddenWidget
+        return field
 # register MarkupField to use the custom widget in the Admin
 from django.contrib.admin.options import FORMFIELD_FOR_DBFIELD_DEFAULTS

File markitup/

 from markitup.util import absolute_url
 import posixpath
-class MarkupTextarea(forms.Textarea):
+class MarkupInput(forms.Widget):
     def render(self, name, value, attrs=None):
         if value is not None:
             # Special handling for MarkupField value.
                 value = value.raw
             except AttributeError:
-        return super(MarkupTextarea, self).render(name, value, attrs)
+        return super(MarkupInput, self).render(name, value, attrs)
+class MarkupTextarea(MarkupInput, forms.Textarea):
+    pass
+class MarkupHiddenWidget(MarkupInput, forms.HiddenInput):
+    pass
 class MarkItUpWidget(MarkupTextarea):