Vous êtes sur la page 1sur 9

ChronoForms v3.

0 Tutorials
#5 Saving data to the database

CHRONO
E N G I N E
www.chronoengine.com
Saving data to the database

This tutorial tells you how to create a database table to save the data from your form.

Create the table 1

Go to the Forms Manager. Select the checkbox for your form then click the 'Create Table' icon in the tool bar.

Saving data to the database - 1 Tutorial by GreyHead ~ www.greyhead.net


Create the table 2

Make a note of the table name in the box at the top. This will probably be jos_chronoforms_ + your form name.
Then, for a simple table, it is enough to check the 'Create Column?' box which will select all the fields; then click Save Table. This will create a
new table in the database and create the code to save the data from your form.

There are several other options on this page: to set indexes for the table, to add fields or to skip them and to set field types. Unless you are familiar
with databases and understand these options it's best to leave them alone for the moment.

The one exception is that if you have any 'textareas' in your form where you expect long entries, it might be useful to select 'TEXT' as the Column
Type for that field.

Saving data to the database - 2 Tutorial by GreyHead ~ www.greyhead.net


Save the table

Once you click Save Table you will be returned to the Forms Manager and you should see the message 'Table has been created successfully'.
Notice that the Tables Connected column to the right is still empty.
Click the form name to edit the form.

Saving data to the database - 3 Tutorial by GreyHead ~ www.greyhead.net


Make the connection

In the Form Editor: select the 'DB Connection' tab; set 'Enable Data storage' to Yes; scroll down to find your table name (from step 3 above)
and select it. Click the Save icon in the toolbar to save your form.

Note: you can select other tables here instead of the one created for this form. This is a very powerful feature that allows your forms to interact with
other elements of Joomla. It also has the potential to damage your Joomla installation so do not use it unless you are certain that you know exactly
what you are doing.

Saving data to the database - 4 Tutorial by GreyHead ~ www.greyhead.net


Confirm the table connection

You should now see that the table name appears in the Tables Connected column to confirm the connection.
Your database connection is now complete . . . we will test it and then look at a couple of other ChronoForms features.

Open your form in a new window or tab (using the Link here is the simplest way) and submit a test entry.
Once you've done that return to the Form Manager and click the Table link.

The data browser

Here you will see the ChronoForms data browser. Using the checkboxes you can select and delete records; and you can backup your data to an

Saving data to the database - 5 Tutorial by GreyHead ~ www.greyhead.net


Excel or a CSV (comma separated variable) file to save a copy or to use it in another application.
You can click on a record id to view the record contents.

Viewing the record

This is a very simple display showing the data submitted from your form. The earlier fields are automatically created by ChronoForms. They make
sure that the data is uniquely identified and record when it was submitted and by whom.
Click the Cancel icon in the toolbar to return to the table viewer; and then Cancel again to return to the Form Manager.

Saving data to the database - 6 Tutorial by GreyHead ~ www.greyhead.net


The Autogenerated Code tab

Finally, go to the Form Editor again and click the AutoGenerated Code tab.
You can leave all these settings as they are for the moment. They give you some extra controls over the way form data is handled when it is
saved.

Saving data to the database - 7 Tutorial by GreyHead ~ www.greyhead.net


Note: Although you can edit the Main code box here ChronoForms will not save your changes!!

Saving data to the database - 8 Tutorial by GreyHead ~ www.greyhead.net

Vous aimerez peut-être aussi