-
Notifications
You must be signed in to change notification settings - Fork 638
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
Copy field values from other sites #14056
Copy field values from other sites #14056
Conversation
# Conflicts: # src/controllers/ElementsController.php # src/web/assets/cp/dist/cp.js # src/web/assets/cp/dist/cp.js.map # src/web/assets/cp/dist/css/cp.css # src/web/assets/cp/dist/css/cp.css.map # src/web/assets/cp/src/js/ElementEditor.js
a366570
to
5ccacd8
Compare
// if we're copying a single field (so we have the hud, not the modal) | ||
if (this.copyHud) { | ||
// check if the field is classed as nested | ||
return Garnish.hasAttr(this.copyHud.$trigger, 'data-nested'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since non-NEM fields are also creating drafts, could we just remove this method and assume that every time we’re copying field values, a draft should be created first?
If so we can also remove craft\fieldlayoutelements\BaseField::isNested()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s needed to allow copying fields inside of a matrix field that’s set to editable blocks mode to work.
Replication steps:
- have at least 2 sites set up
- create a matrix field in editable blocks mode with the propagation method set to “all”
- the matrix field should have an entry type that has, e.g. plain text field set to be translatable
- create a section that’s enabled for both sites; its entry type should use the matrix field we just created
- create an entry in that section, add a block to the matrix field, fill out the plain text field, fully save the entry
- edit the entry in the second site, change the plain text field inside the matrix field so that it’s clear it’s from the other site & fully save
- in either site, edit the entry and copy the plain text field inside the matrix field from the other site
with the code you asked about, it works as expected; without it, it does not
Not possible to copy everything in a way that's consistent with individual field value copying, without dropping support for Matrix (at which point, what's the point?)
3286008
to
d6f9669
Compare
Continuation of #12436 but instead of handling the copy server-side, the controller will return fragments of HTML that we use to replace fields and immediately save a draft. This simplifies the logic a bit as we can rely on existing "Save Draft" processes to save the values.
Description
Adds a new “Copy value from site…” action to translatable fields’ action menus on element edit pages, making it possible to copy the field value from another site over to the current site.
Plugin-supplied field types that want to add support for cross-site value copying will need to start implementing the new
CrossSiteCopyableFieldInterface
.