|
@@ -341,11 +341,41 @@ To allow unicode values, add the data attribute value;
|
|
|
/>
|
|
|
```
|
|
|
|
|
|
-### Title field auto sync with the slug field on Pages now relies on data attributes
|
|
|
+### Changes to title / slug field synchronisation
|
|
|
|
|
|
-The title field will sync its value with the slug field on Pages if the Page is not published and the slug has not been manually changed. This JavaScript behaviour previously attached to any field with an ID of `id_title`, this has now changed to be any field with the appropriate Stimulus data attributes.
|
|
|
+The mechanism for synchronising the slug field with the page title has changed, and is no longer hard-coded to activate on fields named 'title'. Notably, this change affects page panel definitions that use `FieldPanel("title")` directly (rather than the convention of extending `Page.content_panels`), as well as non-page models such as snippets.
|
|
|
|
|
|
-If your project is using the built in `title` and `slug` fields without any customisations, you will not need to do anything differently. However, if you were relying on this behaviour or the `window.initSlugAutoPopulate` global, please read ahead as you may need to make some changes to adopt the new approach.
|
|
|
+To assist in upgrading these definitions, Wagtail 5.0.2 provides a new [](title_field_panel) class to be used in place of `FieldPanel("title")`. For example:
|
|
|
+
|
|
|
+```python
|
|
|
+from wagtail.admin.panels import FieldPanel, MultiFieldPanel
|
|
|
+
|
|
|
+ # ...
|
|
|
+ content_panels = [
|
|
|
+ MultiFieldPanel([
|
|
|
+ FieldPanel("title"),
|
|
|
+ FieldPanel("subtitle"),
|
|
|
+ ]),
|
|
|
+ ]
|
|
|
+```
|
|
|
+
|
|
|
+should become:
|
|
|
+
|
|
|
+```python
|
|
|
+from wagtail.admin.panels import FieldPanel, MultiFieldPanel, TitleFieldPanel
|
|
|
+
|
|
|
+ # ...
|
|
|
+ content_panels = [
|
|
|
+ MultiFieldPanel([
|
|
|
+ TitleFieldPanel("title"),
|
|
|
+ FieldPanel("subtitle"),
|
|
|
+ ]),
|
|
|
+ ]
|
|
|
+```
|
|
|
+
|
|
|
+If you have made deeper customisations to this behaviour, or are unable to upgrade to Wagtail 5.0.2 or above, please read on as you may need to make some changes to adopt the new approach.
|
|
|
+
|
|
|
+The title field will sync its value with the slug field on Pages if the Page is not published and the slug has not been manually changed. This JavaScript behaviour previously attached to any field with an ID of `id_title`; this has now changed to be any field with the appropriate Stimulus data attributes.
|
|
|
|
|
|
There is a new Stimulus controller `w-sync` which allows any field to change one or more other fields when its value changes, the other field in this case will be the slug field (`w-slug`) with the id `id_slug`.
|
|
|
|