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:
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:
field_settings table holds information for option lists (which I want to use)
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?
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?