Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Clone problem

Questions related to using nuBuilder Forte.
Post Reply
Diggger5
Posts: 6
Joined: Wed Feb 01, 2023 5:08 pm
Has thanked: 1 time

Clone problem

Unread post by Diggger5 »

Cloning problem

Hello,
I created a form where I set clonable = no for some fields, but otherwise the values ​​are copied. It worked in Nubuilder 4.5, but I experience this everywhere with newer versions. What is the error?

Thanks!
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Clone problem

Unread post by kev1n »

Hi,

To resolve the cloning issue, try replacing the following line in nuform.php:

Code: Select all

function nuGetFormModifyObject($object, $formObject, $row, $recordId, $data, $numObjects, $cloneableObjects, $dbFields) {
with

Code: Select all

function nuGetFormModifyObject($object, $formObject, $row, $recordId, $data, $numObjects, &$cloneableObjects, $dbFields) {
This change passes $cloneableObjects by reference, which may fix the problem in newer versions of nuBuilder.

Give it a try and let me know if it works!
Diggger5
Posts: 6
Joined: Wed Feb 01, 2023 5:08 pm
Has thanked: 1 time

Re: Clone problem

Unread post by Diggger5 »

Hi Kev1n!

Thanks for the quick reply!
Yes, this solved the clone problem!
But I faced another problem.
Some objects are clonable = no and No Duplicates. The first clone works fine, the data disappears from the fields. But when I try this again, when saving a new record, I get a message that the object has a duplicate, even though the field is empty.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Clone problem

Unread post by kev1n »

Just to confirm that I understand what you're trying to do:

Some fields are marked as clonable = "no" and set to "No Duplicates".
When you clone the form, those fields are blanked out as expected.
You save the form — everything works fine.

Then, when you clone the form again, the same fields are blanked out again.
However, this time you get a validation error saying something like “objectXYZ has a duplicate.”

I’m assuming this happens because, technically, there’s already an empty value for that field in the database, and the system treats that as a duplicate.
But since the fields are blank, we would expect multiple empty values to be allowed.

Do I have a correct understanding of the issue?
Diggger5
Posts: 6
Joined: Wed Feb 01, 2023 5:08 pm
Has thanked: 1 time

Re: Clone problem

Unread post by Diggger5 »

Yes, you understand the problem correctly.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Clone problem

Unread post by kev1n »

I believe the issue has been resolved — please give it another try.

Replace /core/nudata.php with the attached file:
nudata.php
Test it again and let me know if everything works as expected.
You do not have the required permissions to view the files attached to this post.
Diggger5
Posts: 6
Joined: Wed Feb 01, 2023 5:08 pm
Has thanked: 1 time

Re: Clone problem

Unread post by Diggger5 »

Works like a charm!!!

Is it possible that these changes will be included in future updates?

Thanks Kev1n!!
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Clone problem

Unread post by kev1n »

Thanks for testing. These changes are already included on Github :D
Post Reply