mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 17:23:15 +00:00
specify a custom widget for StreamFieldPanel (that currently doesn't do very much)
This commit is contained in:
parent
d1e36651af
commit
59bf2b2ba5
3 changed files with 13 additions and 1 deletions
|
|
@ -619,7 +619,9 @@ Page.settings_panels = [
|
|||
|
||||
|
||||
class BaseStreamFieldPanel(BaseFieldPanel):
|
||||
pass
|
||||
@classmethod
|
||||
def widget_overrides(cls):
|
||||
return {cls.field_name: widgets.StreamWidget()}
|
||||
|
||||
def StreamFieldPanel(field_name):
|
||||
return type(str('_StreamFieldPanel'), (BaseStreamFieldPanel,), {
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ def edit(request, page_id):
|
|||
form.clean = clean
|
||||
|
||||
if form.is_valid() and not page.locked:
|
||||
raise Exception(repr(form.cleaned_data))
|
||||
page = form.save(commit=False)
|
||||
|
||||
is_publishing = bool(request.POST.get('action-publish')) and page_perms.can_publish()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import json
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.forms import widgets
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from wagtail.utils.widgets import WidgetWithScript
|
||||
from wagtail.wagtailcore.models import Page
|
||||
|
|
@ -53,3 +54,11 @@ class AdminPageChooser(WidgetWithScript, widgets.Input):
|
|||
app=content_type.app_label,
|
||||
model=content_type.model)),
|
||||
parent=json.dumps(parent.id if parent else None))
|
||||
|
||||
|
||||
class StreamWidget(widgets.Widget):
|
||||
def render(self, name, value, attrs=None):
|
||||
return mark_safe("<strong>hello from StreamWidget</strong>")
|
||||
|
||||
def value_from_datadict(self, data, files, name):
|
||||
return 'lol idk'
|
||||
|
|
|
|||
Loading…
Reference in a new issue