Adding a Date element is slightly different from adding any other element, there are three steps.
Step 1
Pick a unique name for the element, choose a name for your new element that is not currently used by another element. The name should be all lower case and multiple words should be joined by an underscore. If this is the first date element in your form a good name would be date
.
Step 2
Add the HTML for the form element in your web page. The easiest way to add another form element is to copy the existing HTML code for the element, including all surrounding wrappers. There is an example of the Date element HTML in the file example-all-elements.html. So to copy the entire element you would select the all the HTML code between the comments:
1 2 3 | <!-- Begin Date element --> ... <!-- End Date element --> |
<!-- Begin Date element --> ... <!-- End Date element -->
Paste the HTML into your own form in the position you want.
Step 3
Add the form element to the process.php file to make the PHP script aware of the new form element, you will need to edit the file quform/process.php. You will need to create a new Quform_Element_Date object for your new field, just copy the code below for the Date element (taken from the file quform/process-all-elements.php).
12
3
| $date = new Quform_Element_Date('date', 'Date');$date->addValidators(array('required', 'date')); $form->addElement($date); |
$date = new Quform_Element_Date('date', 'Date'); $date->addValidators(array('required', 'date')); $form->addElement($date);
- On line 1, if your unique name from Step 1 is not
date
, replace the text inside the single quotes'date'
with your unique name. It is important that this matches the first part of thename=""
attribute of the select elements in the HTML (before the [month], [day], [year] parts). This tells the PHP script what element you are referring to.