StandardPage.default_edit_handler_class = get_page_edit_handler(StandardPage)
StandardPage.default_editor_form_class = get_form_for_model(StandardPage,
formsets=StandardPage.default_edit_handler_class.required_formsets(),
widgets=StandardPage.default_edit_handler_class.widget_overrides())
StandardPage.default_edit_handler_class._form_class = StandardPage.default_editor_form_class
class StandardPageCustomForm(StandardPage.default_editor_form_class):
def __init__(self, data=None, files=None, instance=None, prefix=None, **kwargs):
if instance:
# do custom stuff to the instance
super(StandardPageCustomForm, self).__init__(data, files, instance=instance, prefix=prefix, **kwargs)
# do custom stuff to the form after Wagtail builds it, like...
self.fields['title'].label = u"Something other than Title"
class StandardPageCustomEditHandler(StandardPage.default_edit_handler_class):
def __init__(self, instance=None, form=None):
super(StandardPageCustomEditHandler, self).__init__(instance=instance, form=form)
if instance:
# do custom stuff
_form_class = StandardPageCustomForm
PAGE_EDIT_HANDLERS[StandardPage] = StandardPageCustomEditHandler