Page 1 of 1

Clone problem

Posted: Tue Apr 29, 2025 11:09 am
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!

Re: Clone problem

Posted: Tue Apr 29, 2025 12:18 pm
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!

Re: Clone problem

Posted: Tue Apr 29, 2025 1:20 pm
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.

Re: Clone problem

Posted: Tue Apr 29, 2025 2:39 pm
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?

Re: Clone problem

Posted: Tue Apr 29, 2025 3:24 pm
by Diggger5
Yes, you understand the problem correctly.

Re: Clone problem

Posted: Tue Apr 29, 2025 9:57 pm
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.

Re: Clone problem

Posted: Wed Apr 30, 2025 9:48 am
by Diggger5
Works like a charm!!!

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

Thanks Kev1n!!

Re: Clone problem

Posted: Wed Apr 30, 2025 9:52 am
by kev1n
Thanks for testing. These changes are already included on Github :D