Jump to content

Multi-language fields won't save while inside a repeater

Recommended Posts

Hey guys,

I'm having a hard time troubleshooting this one: my multilanguage fields save data outside repeaters, but inside any repeater they just won't save, unlike all other fieldtypes.

What I've tried so far:

  • Recreating the repeater matrix from scratch — problem persists
  • Using multi-language fields on a regular repeater instead of a repeater matrix — problem persists
  • Removing all language support modules and reinstalling — problem persists
  • If I change the multi-language fields into single-language types, they start saving right, but if I change them back to multi-language, the problem persists.
  • Changing the multilanguage field via API `$page->repeaterfield[0]->setAndSave("title","Meow")` — works, but I need it in the admin form

 To try to figure out the problem I did this:

$wire->addHookAfter("Pages::saved(template=repeater_content)", function($event) {
    $page = $event->arguments(0);
    $changes = $event->arguments(1);
    $values = $event->arguments(2);

The hook is only triggered when I also change a non-multi-language field.

On the dumped $page the title field is there like I changed it in the form. But something must happen after Page::saved that restores it back to what it was.

 Where would you look next to find the solution...? Thank you very much for your help!

Link to comment
Share on other sites

I really can't tell if this is a bug or feature, to be honest.

I talked about this with @ryan and he wasn't sure either back when I found this issue.
And yes, that was about at least 2 years back.

So... right now... this seems only to affect PW-sites that were single-language and then were migrated to multi-language support. Which is probably the case here too. I almost never stumble over this, due to my profiles I use for new projects, but YES... it could and will be... kind of a show-stopper in a setup once in a while - as we see here.

But here is the "easy fix"... never use title somewhere else outside of default templates.

I know it sounds weird as re-using fields is such a common task nowadays (for good), but... I learned about the years that title is more or less not a field, rather a tool to define name-based default IDs (besides the regular page ID). I see the title field as something like fkTitle (foreignKeyTitle) which I used to use in Oracle DBs back in my agency times. Way less strict and only applicable with additional selector-queries, but... it's close enough in my use-cases.

In my setups I ALWAYS use headline, subline, topline and similar fields instead of title. Especially in RepeaterMatrix to create unique jumplinks.

tl;dr (my definition for the title-field)

Use title in your templates but never in an ongoing or extended way like using it in RepeaterMatrix Blocks or similar. It's a system field for a reason. Almost like a human-readable ID. That how I handle it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...