-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Plugin extendModel #85
base: main
Are you sure you want to change the base?
Conversation
Fix property `translatable` is not merged when `$translatePlugin->extendModel` is called in multiple times.
this method is not meant to be used elsewhere, it's just a helper in the Plugin class to avoid repeating ourselves... just extend the Page model in the usual way in your plugin. |
How to extend "translatable" property in usual way? Can you give me example? |
What version of WinterCms do you use? |
I checked by command: This the result:
|
There were changes in winter 1.2.5 that affects the way dynamic properties get created because of php 8.2+ deprecation (https://php.watch/versions/8.2/dynamic-properties-deprecated) So we're now using winter dynamic properties but there may still be unexpected issues related to this. Are you adding translatable items before or after the translatable property has been added to the CMS page by the translate plugin? |
Here are the commits that changed this: |
|
I think we need to add another test cases for dynamic attribute, such as merging array values |
you're right. if you can do this as part of this PR, that would be awesome. |
I will try it, but I can start it on the next week, probably in the monday (GMT+7). |
Fix property
translatable
is not merged when$translatePlugin->extendModel
is called in multiple times.I need to add custom field on CMS Page with translation too (in my plugin). I was using
backend.form.extendFields
event to addmeta_keywords
field with typemltext
. This code to add translation to it.But it remove translation to other fields
title
,url
, etc.. After I debug it, I found thatexetendModel
function is not merging the translatable attributes. Current code:if (dynamic) property already exists, because was called in my plugin. Then this code fail to merge the attributes.
Because the getter function will prioritize the attribute from dynamic properties, but the setter will set on instance attributes directly.
Leaving condition like this:
Theres 2 property, in instance attributes and in dynamic properties with different values.
This PR fixt that, with setting the attributes in dynamic property