You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Localised copy doesn't trigger when ClassName changes
This may be an edge case but it's quite important for the Fluent + Elemental setup
Test setup
Page - "out of the box" model type CustomPage - page with a has_one relation which uses localised_copy and this relation is automatically populated when a page is created (like ElementalArea)
Create new Page, localise in int and us
Current locale is int
Change Page class to CustomPage and save
This triggers the relation to be populated for the int locale but not for the us locale
The most common case is ElementalArea as this model is automatically attached when ClassName is changed (as the page relation becomes available).
Possible solution
Something like if we have localised_copy setup then we wold search for all localised records of the current model and check if this relation is populated. If it's not populated we would duplicate the related model from the current locale and attach. This should happen onAfterWrite(). We should probably use writeWithoutVersion or raw query if needed to attach relations.
The text was updated successfully, but these errors were encountered:
and this relation is automatically populated when a page is created (like ElementalArea)
Should localised_copy create a brand new record each time, or only copy an existing record to the new locale when it's localised? I'm not sure it's clear that's the expectation. Especially if you want localised_copy an an optional record (e.g. page banner, but there doesn't HAVE to be a banner).
My understanding is that localised_copy means you always create a new record. For example if you copy to the same locale twice the second time will create a new record. I'll review how localised copy works currently in detail and ideally I'll put up a POC for review. Maybe this is something that belongs to the Fluent/Elemental module though.
Localised copy doesn't trigger when ClassName changes
This may be an edge case but it's quite important for the Fluent + Elemental setup
Test setup
Page
- "out of the box" model typeCustomPage
- page with a has_one relation which useslocalised_copy
and this relation is automatically populated when a page is created (like ElementalArea)Page
, localise inint
andus
int
Page
class toCustomPage
and saveint
locale but not for theus
localeThe most common case is ElementalArea as this model is automatically attached when ClassName is changed (as the page relation becomes available).
Possible solution
Something like if we have
localised_copy
setup then we wold search for all localised records of the current model and check if this relation is populated. If it's not populated we would duplicate the related model from the current locale and attach. This should happenonAfterWrite()
. We should probably use writeWithoutVersion or raw query if needed to attach relations.The text was updated successfully, but these errors were encountered: