Closed (works as designed)
Project:
Field clone
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 May 2017 at 11:05 UTC
Updated:
15 May 2017 at 11:17 UTC
Jump to comment: Most recent
Comments
Comment #2
geek-merlinHmm, if the node is already saved, this should be just normal operations of the module.
If you want to clone paragraphs inside the form (so they are not yet saved anywhere) this sounds like a totally different module.
Can this help you?
Comment #3
geraldito commentedThanks for your answer. My issue is more about creating clones of paragraphs in new (and not already saved) nodes. So you say that your module is not appropriate for doing that. Perhaps I should look for a Javascript solution as data has to be copied from fields inside the add node form.
Comment #4
geek-merlinDo you need "add empty" as well as "clone"? Do you need to copy different items or always the same?
If the use case is "always clone the first one" then you may intercept the "add" process.
Comment #5
geraldito commentedIdeally I would have a "add empty" and additionally a "clone" button. But I could live with "always clone the first/last one".
So you propose to intercept the "add" process by hook_form_alter or by hook_preprocess_paragraph? Thanks again for your help.
Comment #6
geek-merlin> So you propose to intercept the "add" process by hook_form_alter or by hook_preprocess_paragraph? Thanks again for your help.
I can't remember what we have there, and my gut feeling is to go deeper than form alter, so hook_preprocess_paragraph might be a good candidate. For the experienced it might even be possible to decorate the paragraphs object (if you want to do that and invest some learning, look up "decorator pattern").
Comment #7
geraldito commentedI just found out that the Paragraphs Experimental Widget shows by default a "Duplicate" button which actually does what I'm looking for: Cloning the content of all paragraph fields into a new paragraph. Thanks for your help!