Skip to content
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

Button for Duplicating Component not working #5918

Open
SmolmangoBFX opened this issue Nov 20, 2024 · 0 comments
Open

Button for Duplicating Component not working #5918

SmolmangoBFX opened this issue Nov 20, 2024 · 0 comments

Comments

@SmolmangoBFX
Copy link

Heyo,

So I am working on creating a form that is like a treatment log used in the healthcare/aesthetics field. Essentially, I am trying to make a button that when pressed will create/Duplicate of a certain component. For example, need to create another section to chart in when doing treatment on another body part (take info in 'panel' and duplicate it). Using this code in the custom event of a button:

let pushed = false;
util.eachComponent(form.components, function(c) {

if (pushed) return;
if (c.key === 'panel') {
const panelValues = c.data || {};

c.data = panelValues;
form.components.push(c);
form.redraw();   
pushed = true; 

}
}, true);


The Button does the duplicate part well but it clears all data on any previous panels and replace it with the content of the most recently pasted panel. I believe it might have to do with the code referring to the key of the panel so it just copies that.

Could someone guide me on where the error in my code is? For reference, here is the JSON of the form:
Thank you!

Duplicate Button form.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant