kopia lustrzana https://github.com/wagtail/wagtail
Resolve error when specifying 'slug' as a read-only field (#11447)
rodzic
222cf7de72
commit
da31733b93
wagtail/admin
panels
|
@ -78,7 +78,11 @@ class TitleFieldPanel(FieldPanel):
|
|||
actions = [widget.attrs.get("data-action", None)] + self.apply_actions
|
||||
attrs["data-action"] = " ".join(filter(None, actions))
|
||||
|
||||
targets = [self.get_target_selector(target) for target in panel.targets]
|
||||
targets = [
|
||||
self.get_target_selector(target)
|
||||
for target in panel.targets
|
||||
if target in self.form.fields
|
||||
]
|
||||
attrs["data-w-sync-target-value"] = ", ".join(filter(None, targets))
|
||||
|
||||
placeholder = self.get_placeholder()
|
||||
|
|
|
@ -2260,6 +2260,25 @@ class TestTitleFieldPanel(WagtailTestUtils, TestCase):
|
|||
"focus->w-sync#check blur->w-sync#apply change->w-sync#apply keyup->w-sync#apply",
|
||||
)
|
||||
|
||||
def test_form_without_slugfield(self):
|
||||
html = self.get_edit_handler_html(ObjectList([TitleFieldPanel("title")]))
|
||||
|
||||
self.assertIsNotNone(html.find(attrs={"class": "w-panel title"}))
|
||||
|
||||
attrs = html.find("input").attrs
|
||||
self.assertEqual(attrs["data-w-sync-target-value"], "")
|
||||
|
||||
def test_form_with_readonly_slugfield(self):
|
||||
html = self.get_edit_handler_html(
|
||||
ObjectList([TitleFieldPanel("title"), FieldPanel("slug", read_only=True)]),
|
||||
instance=EventPage(),
|
||||
)
|
||||
|
||||
self.assertIsNotNone(html.find(attrs={"class": "w-panel title"}))
|
||||
|
||||
attrs = html.find("input").attrs
|
||||
self.assertEqual(attrs["data-w-sync-target-value"], "")
|
||||
|
||||
def test_not_using_apply_actions_if_live(self):
|
||||
"""
|
||||
If the Page (or any model) has `live = True`, do not apply the actions by default.
|
||||
|
|
Ładowanie…
Reference in New Issue