Page 1 of 1

Cloning a form

Posted: Mon Mar 26, 2018 2:13 pm
by Timo
I have a form, which is very extensive and has about 60 fields. Now I want to duplicate it so that I don't have to recreate all the fields again. "Clone" unfortunately only copied the form but not the individual fields or the layout. Did I overlook anything?

Re: Cloning a from

Posted: Mon Mar 26, 2018 11:31 pm
by admin
Timo,

Cloning a Form won't clone its Objects.

You can redirect a Browse Form to whatever Edit Form you like - so in most cases, you don't have to create (and maintain) duplicate Edit Forms.
redirect2.PNG
Steven

Re: Cloning a form

Posted: Tue Mar 27, 2018 10:21 am
by Timo
Well, in my case, it's not an exact duplicate. The underlying table is going to be another one and other fields are added or removed. Are there any other possibilities?

Re: Cloning a from

Posted: Wed Mar 28, 2018 2:56 am
by admin
Timo,

You'll need to create it again yourself.

Steven

Re: Cloning a form

Posted: Wed Mar 28, 2018 4:53 am
by Timo
I found out that the objects are stored in a table zzzzsys_object. Can't you just duplicate the rows of the fields you'd like to clone and change a few fields like ids? Would that be reasonable?

Re: Cloning a form

Posted: Wed Mar 28, 2018 8:25 am
by admin
Timo,

You could try that.

Steven

Re: Cloning a form

Posted: Thu Mar 29, 2018 4:01 am
by Timo
All right, I was able to copy the objects with 1 sql statement. Then I only had to add a few minor settings which were not copied.

Maybe such a function could be integrated into nuBuilder?

Code: Select all

INSERT INTO `zzzzsys_object`(`zzzzsys_object_id`, `sob_all_zzzzsys_form_id`, 
`sob_all_table`, `sob_all_type`, `sob_all_id`, `sob_all_label`, `sob_all_zzzzsys_tab_id`, 
`sob_all_order`, `sob_all_top`, `sob_all_left`, `sob_all_width`, `sob_all_height`, 
`sob_all_cloneable`, `sob_all_align`, `sob_all_validate`, `sob_all_access`, 
`sob_calc_formula`, `sob_calc_format`, `sob_run_zzzzsys_form_id`, `sob_run_filter`, 
`sob_run_method`, `sob_run_id`, `sob_display_sql`, `sob_select_multiple`, `sob_select_sql`, 
`sob_lookup_code`, `sob_lookup_description`, `sob_lookup_description_width`, `sob_lookup_autocomplete`, 
`sob_lookup_zzzzsys_form_id`, `sob_lookup_javascript`, `sob_lookup_php`, `sob_lookup_table`, 
`sob_subform_zzzzsys_form_id`, `sob_subform_foreign_key`, `sob_subform_add`, `sob_subform_delete`,
`sob_subform_type`, `sob_subform_table`, `sob_input_count`, `sob_input_format`, `sob_input_type`,
`sob_input_javascript`, `sob_html_code`, `sob_html_chart_type`, `sob_html_javascript`, `sob_html_title`,
`sob_html_vertical_label`, `sob_html_horizontal_label`, `sob_image_zzzzsys_file_id`) 
SELECT LEFT(MD5(UUID()),15) as zzzzsys_object_id, ---generate a new id /maybe not the best way but it worked for me.
       '7ab3b20fcc1d30e' as sob_all_zzzzsys_form_id, -- new form id
       replace(`sob_all_table`,'table1','table2') as sob_all_table, -- in my case, the tables have different prefixes, replace
       `sob_all_type`,
       replace(`sob_all_id`,'table1','table2'), -- in my case, the ids have different prefixes, replace
       `sob_all_label`,
       '5ab9c10b3c20d1c' as sob_all_id, -- new tab id
       `sob_all_order`,
       `sob_all_top`,
       `sob_all_left`,
       `sob_all_width`,
       `sob_all_height`,
       `sob_all_cloneable`,
       `sob_all_align`,
       `sob_all_validate`,
       `sob_all_access`,
       `sob_calc_formula`,
       `sob_calc_format`,
       `sob_run_zzzzsys_form_id`,
       `sob_run_filter`,
       `sob_run_method`,
       `sob_run_id`,
       `sob_display_sql`,
       `sob_select_multiple`,
       `sob_select_sql`,
       `sob_lookup_code`,
       `sob_lookup_description`,
       `sob_lookup_description_width`,
       `sob_lookup_autocomplete`,
       `sob_lookup_zzzzsys_form_id`,
       `sob_lookup_javascript`,
       `sob_lookup_php`,
       `sob_lookup_table`,
       `sob_subform_zzzzsys_form_id`,
       `sob_subform_foreign_key`,
       `sob_subform_add`,
       `sob_subform_delete`,
       `sob_subform_type`,
       `sob_subform_table`,
       `sob_input_count`,
       `sob_input_format`,
       `sob_input_type`,
       `sob_input_javascript`,
       `sob_html_code`,
       `sob_html_chart_type`,
       `sob_html_javascript`,
       `sob_html_title`,
       `sob_html_vertical_label`,
       `sob_html_horizontal_label`,
       `sob_image_zzzzsys_file_id`
FROM `zzzzsys_object`
WHERE sob_all_zzzzsys_form_id = '5ac3a290a31510c' -- old form id

Re: Cloning a form

Posted: Fri Mar 30, 2018 12:49 am
by admin
Timo,

It might be sometime.

Steven