With HTML_QuickForm version 3.1, you can have a consistent look across all your forms and a simplified file upload. This chapter starts with the basics then shows you how to process submitted form data with HTML_QuickForm. (From the book, Essential PHP Tools: Modules, Extensions, and Accelerators, by David Sklar, Apress, 2004, ISBN: 159059280.)
The reset element produces an HTML <input type="reset"> tag. This element is identical to the submit element except that the reset button resets all elements in the form to their default values instead of submitting the form.
The following is the sample usage:
$form->addElement('button','check','Check the Page','onClick="checkPage();"');
The following is the sample HTML:
<td align="right" valign="top"<<b></b></td>
<td valign="top" align="left"<<input onclick="checkPage();" name="check" value="Check the Page" type="button" /></td>
The image element produces an HTML <input type="image"> tag. This displays an image in the form. A user can click the image to submit the form. The x and y coordinates of the pixel the user clicked in the image are submitted with the form as well.
These are the valid arguments when creating an image element:
$elementName: The name attribute of the elementís <input> tag.
$src: The src attribute is a relative or absolute URL of the image to display.
$attributes: Arbitrary element attributes, as a string or an associative array
If a user submits the form by clicking in the upper-leftmost corner of the image, the submitted form variables state_map_x and state_map_y are both set to 0. A click ten pixels to the right and eight pixels down sets state_map_x to 10 and state_map_y to 8. Because the name attribute of the <input type="image"> tag is state_map, the submitted form variable state_map_x is set to the horizontal position in the image of the userís click. Similarly, the submitted form variable state_map_y is set to the vertical position in the image of the userís click.
The same rules apply for URLs in the src attribute of <input type="image"> tags as they do in the src attribute of an <img< tag. If you specify a full URL, beginning with http://, the browser fetches the image from that location. If you just specify a pathname, the browser looks for the image relative to the URL of the page in which the form appears.
This chapter is from Essential PHP Tools: Modules, Extensions, and Accelerators, by David Sklar, (Apress, 2004, ISBN: 1590592808). Check it out at your favorite bookstore today.