Forums

include controls created in custon code in dbsave

stikki 27 Nov, 2016
Hi

I created a form and used the designer tab to add fields.

The form also reads in data from a table and in a custom box I create checkboxes that take names and values from the data read into the form. The form displays as I want it.

How can I include the values from the checkboxes in the form data when it is saved? At the moment, only data from the controls created in designer view are saved.

Thanks

Mikki
GreyHead 27 Nov, 2016
Hi Mikki,

a. Add a Debugger to the On Submit event temporarily so that you can see the data that is being submitted and saved.

b. Click the Delete Cache icon in the Forms Manager toolbar if you have made any changes to the database columns.

c. If there is a Checkbox group in the form then you may need to use a Handle Arrays action to convert the array into a list for saving.

Bob
stikki 27 Nov, 2016
Thanks Bob

I have added a debugger and it shows the values from the selected checkboxes are in the array - you can see them here - I selected Day1 Day 3 and Day5:
Array
(
    [option] => com_chronoforms5
    [chronoform] => add-bookings
    [event] => submit
    [first_name] => Tom
    [last_name] => Jones
    [no_of_children] => 0
    [child1_firstname] => Jenny
    [child1_lastname] => Jones
    [child2_first_name] => 
    [child2_last_name] => 
    [Day1] => 19-12-2016
    [Day3] => 21-12-2016
    [Day5] => 23-12-2016
    [button13] => Submit
    [id] => 3
)

But, I guess because these checkboxes were not created with the wizard, they are not included in the SQL in dbsave:
         [0] => INSERT INTO `josqp_chrono_bookings` (`first_name`, `last_name`, `no_of_children`, `child1_firstname`, `child1_lastname`, `child2_first_name`, `child2_last_name`, `user_id`, `uniq_id`, `created`) values ('Tom', 'Jones', '0', 'Jenny', 'Jones', '', '', '0', '1f1f09a0e3fb6661f24868a54e7a3e1bb1ae2fe4', '2016-11-27 16:11:05');

How would I go about editing the SQL that the wizard has generated for the Insert, or would I need to remove the dbsave and add a custom bit of PHP and MYSQL to do the data insert?

If so, can you point me to an example?

Many thanks

Mikki
GreyHead 27 Nov, 2016
Hi Mikki,

Do those columns exist in the database table? If they do, did you click the Delete Cache icon?

Bob
stikki 27 Nov, 2016
1 Likes
Bob

My bad! I used capitals on the form but lower case for the database! So the dbsave loops through everything in the array? That's really cool. Thanks for you help I've learnt a lot today.

Mikki
This topic is locked and no more replies can be posted.