Buy Now
Sign in

FAQ search

How can I use the form data?

Details
Published: Thursday, 29 May 2014 09:22
The 'form data' is the data submitted by a user; plus any extra data that you have looked up from the Joomla! database tables or other sources. This FAQ describes the main ways in which you can access and use this data.

The form data is stored by ChronoForms in a $form->data array that can be accessed from most form Elements and Actions.

Using Form Data in PHP

If you are using a Custom Element element, or a Custom Code action - or one of the other actions that allows PHP then you can access the the data using $form->data['input_name']
If the data has been saved using a Model ID, for example it has been loaded from a DB Record Loader action, then it will be in a sub-array and can be accessed using $form->data['model_id']['input_name']

Please see this FAQ for more detailed information on using form data in PHP

Using Form Data in HTML

Some actions, like the Email Template and the Thank You Message  allow you to enter HTML, in these actions you can use ChronoForms curly brackets syntax to include for data using {input_name} or {model_id.input_name} if the data uses a Model ID.

Using Form Data in action options boxes

Some action options boxes like the Dynamic Email action boxes allow you to enter input names. In this case they should be entered as input_name without brackets or quotes.

Setting the values of inputs using Form Data

If you are using a multi-page form and passing data between pages; or you want to include data from a calling URL in your form then you can add a form input with the same name as the parameter you want to use and the ChronoForms Show HTML action will automatically set the value of the parameter from the $form->data array.
For example, if you are caling your form from a URL that includes an item ID like &item_id=999 then adding a hidden input with the name item_id will let ChronoForms set the value to 999.

ChronoForms automatically adds all the parameters from the Callling URL; any existing POST data; and any data you have specified with a 'Multi Page' action or a 'Session to Data' action into the $form->data array so all of these can be available.