FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dublicate Form Entry
#1
Hello everyone,
I'm building forms were I have a lot of similar Fields. Basically only the label varies.

I already did some research and test programming. First thing I did was look at the mysql database and tried to figure out a solution here. To copy an entry of a form with all its properties four tables are involved (if I'm correct)

form_fields table has most of the properties of a new form field here we add a new entry:
Code:
INSERT INTO `form_fields` (`field_id`, `form_id`, `field_name`, `field_test_value`, `field_size`, `field_type_id`, `is_system_field`, `data_type`, `field_title`, `col_name`, `list_order`, `is_new_sort_group`, `include_on_redirect`) VALUES
(NULL, NR, new, '1', '1char', 14, 'no', 'string', NAME, new, NULL, 'yes', 'no');

form_NR table consists of all the submissions of a form. I'm not interested in them, but the colums are the same as the col_name row in form_fields. So a new column is added:
Code:
ALTER TABLE form_NR ADD new varchar(1) DEFAULT NULL;

field_settings table holds information for option lists (which I want to use)
Code:
SELECT @id := `field_id` FROM `form_fields` WHERE `col_name` = new;
INSERT INTO `field_settings` (`field_id`, `setting_id`, `setting_value`) VALUES
(@id, 45, '1');

field_validation table: here we do the same as for field_settings, just for the validation settings.

This sql code works but its obviously not very comfortable and doesn't check for any errors that may occur in between. All the values have to be changed by hand.

A better solution would be to use the Smarty commands provided by formtools and hook them in the admin_edit_form_fields_tab. I'm just not very familiar with how to use these (ft_commands).

I think it could be quite easy to retrieve all the needed information in this tab and create a field copy from there.

Could you just tell me the ruff order of commands to build and fill a new field?
Maybe there is a cleverer solution for this?
Reply
#2
Hi leob,

I'm not sure I understand what you 'd like to achieve. Is it that you want to make clones of the same form that you can, then, modify (as much or as little as needed)?

If so, the easiest way to do that may be to install and use the Form Backup extension (http://modules.formtools.org/form_backup/).

BTW, the data of each form are stored in the table ft_form_X, where X is the number of the form (e.g., 1 if you have a single form), in case you may want to quicly erase all the data held in a form prior to modifying it.

I hope that helps!




(Apr 2nd, 2015, 4:35 AM)leob Wrote: Hello everyone,
I'm building forms were I have a lot of similar Fields. Basically only the label varies.

I already did some research and test programming. First thing I did was look at the mysql database and tried to figure out a solution here. To copy an entry of a form with all its properties four tables are involved (if I'm correct)

form_fields table has most of the properties of a new form field here we add a new entry:
Code:
INSERT INTO `form_fields` (`field_id`, `form_id`, `field_name`, `field_test_value`, `field_size`, `field_type_id`, `is_system_field`, `data_type`, `field_title`, `col_name`, `list_order`, `is_new_sort_group`, `include_on_redirect`) VALUES
(NULL, NR, new, '1', '1char', 14, 'no', 'string', NAME, new, NULL, 'yes', 'no');

form_NR table consists of all the submissions of a form. I'm not interested in them, but the colums are the same as the col_name row in form_fields. So a new column is added:
Code:
ALTER TABLE form_NR ADD new varchar(1) DEFAULT NULL;

field_settings table holds information for option lists (which I want to use)
Code:
SELECT @id := `field_id` FROM `form_fields` WHERE `col_name` = new;
INSERT INTO `field_settings` (`field_id`, `setting_id`, `setting_value`) VALUES
(@id, 45, '1');

field_validation table: here we do the same as for field_settings, just for the validation settings.

This sql code works but its obviously not very comfortable and doesn't check for any errors that may occur in between. All the values have to be changed by hand.

A better solution would be to use the Smarty commands provided by formtools and hook them in the admin_edit_form_fields_tab. I'm just not very familiar with how to use these (ft_commands).

I think it could be quite easy to retrieve all the needed information in this tab and create a field copy from there.

Could you just tell me the ruff order of commands to build and fill a new field?
Maybe there is a cleverer solution for this?
Reply
#3
Hey garof,

thank you for your answer. I'm trying to do something different. Me and some friends like to bet/tip on sports. Till now I had an excel document calculating the points everybody gets etc. The tips I had to collect via mail and fill them in manually.

So now I'm building forms to collect the data. These forms consist of dropdown fields that are 'required'. Only the label or name of the field changes. (name of the game, home and away team)

What I'm trying to do is to create a bunch of the same fields in a form, with the mentioned properties already selected.

I know the programming I'm doing here probably cost me a lot more time compared to just building the forms by hand, but I like scripting and finding easy/elegant solutions.
Reply
#4
(Apr 7th, 2015, 12:33 AM)leob Wrote: Hey garof,

thank you for your answer. I'm trying to do something different. Me and some friends like to bet/tip on sports. Till now I had an excel document calculating the points everybody gets etc. The tips I had to collect via mail and fill them in manually.

So now I'm building forms to collect the data. These forms consist of dropdown fields that are 'required'. Only the label or name of the field changes. (name of the game, home and away team)

What I'm trying to do is to create a bunch of the same fields in a form, with the mentioned properties already selected.

I know the programming I'm doing here probably cost me a lot more time compared to just building the forms by hand, but I like scripting and finding easy/elegant solutions.

You can play almost all the games in your running shoes but some of that can't be played in running shoes such as basketball. basketballshoesplus if you want to buy basketball shoes at affordable prices with all of the best qualities.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)