Open mskapusuz opened 1 year ago
I've reviewed this ticket and fixed it here - https://github.com/Codeinwp/woocommerce-product-addon/pull/362
@girishpanchal30 seems like you are making that readonly, I want to avoid those to sync when there is a value already saved, people can still change it if they want, but only if they change that field and not the title one.
@selul I attempted to avoid syncing when saving data, but it isn't possible because data_name
is stored in a serialized format within the_meta
.
I also tried retrieving the existing the_meta
and replacing the data_name
, but this approach seems to cause an issue when reordering fields.
So I've just made it read-only and skipped the field update while editing the title.
@girishpanchal30 I'm not sure if I get the issue, this looks like a frontend JS issue and has nothing to do with changing how we store the data or PHP side?
The logic is simple from my end, when editing an existing field, we can disable the js that changes the data name when I edit the title?
Am I missing something?
'm not sure if I get the issue, this looks like a frontend JS issue and has nothing to do with changing how we store the data or PHP side?
On the PHP side, data is saved in a serialized format along with the POST data.
The logic is simple from my end, when editing an existing field, we can disable the js that changes the data name when I edit the title?
I've disabled it when the field is in read-only mode.
@girishpanchal30 instead of making it readonly, we can allow editing it when the user is directly editing that. RIght now there is no way to change that name, which he was able to do before.
@selul I've removed the readonly
attribute and disabled the auto data name update. Please check with the latest commit.
@girishpanchal30 now when I add a new field, to an existing group, when writing the title the data is no longer being added automatically as before.
@selul Fixed it with the latest commit.
Currently, when you try to edit a field title; the dataname is changed as automatically. That's good for the fresh fields, but it's not good for editing the fields.
That dataname is saved in order item meta, therefore if the dataname of the field has been changed, it affects lots of places:
https://vertis.d.pr/i/pIi5TB
Proposal
When we are in the edit screen, we should disconnect the data field from the title, when the title is edited, we should not change the data field and user will need to change it manually.