RSform!Pro allows you to add your custom PHP code in various parts of you form.
You can define code that will be executed upon form form display. To do this, select the form you wish to customize, go to the Scripts tab and add your custom code in the "Script called on form display " textarea. One important note is that in the Scripts called on form display area, the $formLayout variable is available. Basically this variable will hold all the actual HTML of the form in question. This can be rather usefull in some situations. For example you can change the default assigned id of the form:
To change it just place the following script in the Scripts called on form display area:
$formLayout = str_replace('userForm','test',$formLayout);
The form's HTML code will be displayed like this, after the script runs:
The Scripts called on form process area allows you to control the data that has been submitted, but hasn't been stored inside the database and hasn't been used in the emails (if any configured). The actul form values are stored inside the PHP $_POST variable, and can be accessed as described below:
- text field, hidden field, text area, calendar, captcha, button, support ticket: $_POST['form']['name_of_field_here']
- radio and checkbox group: $_POST['form']['name_of_field_here'][index]
- dropdown: $_POST['form']['name_of_field']
The Scripts called after form process can and should be used to control the redirect process, after the form has been submitted. This is particuallary usefull for payment gateways control, where, after form submissions you are redirected to a separate payment page. To add a simple redirect you can use the following:
In the Email Scripts tab you can access two new script areas from RSForm! Pro:
The Script called before the User Email is sent permits you to edit the User Email before it is sent to the user. You can modify the email by accessing the $userEmail array, which contains all the information that will be sent in the email.
And the Script called before the Admin Email is sent where you will be able to customize the Admin Email before it is sent. In order to modify it you can edit the $adminEmail array, which contains all the information that will be sent in the email.
For debugging purposes you should use die(); statements after echo or print_r();. For example: