Now, form generation engine collects the information about formelements bycalling<wbr><em>element_info()</em><wbr>function.This in turn calls<em>hook_element()</em>, which might beimplemented by other modules. We can use this hook to create ourown specialized element types, eg textbox which only takes numericinput.</wbr></wbr>
Now engine know the definition of all element type, so it next itwill look for form validation function. The form validationfunction to use can be specified in any of theforms<wbr><em>#validate</em>,or<em>formID_validate()<wbr></wbr></em>or<wbr><em>#base_validate()</em>.<wbr><em>#base</em><wbr>isthe value that you specify with the form array.</wbr></wbr></wbr></wbr>
Engine will look for submit function to which the form will besubmitted. They can be specified asvalue<wbr><em>#submit<wbr></wbr></em>for key,or<em>formID_submit()</em><wbr>functionor<wbr><em>#base_submit()</em><wbr>function.Once it gets the submit function for the form itcalls<wbr><em>hook_form_alter()</em><wbr>togive any module which wants to change the form. Basically it’s ourtime to modify someone else’s form to add or remove the inputfields and/or descriptions.</wbr></wbr></wbr></wbr></wbr></wbr>
Form elements are now declared in array fashion, with thehierarchical structure of the form elements themselves as arrayelements (which can be nested), and each form elementsproperties/attributes listed as array elements in key/valuepairs--the key being the name of the property/attribute, and thevalue being the value of the property/attribute. For example,here's how to go about constructing a textfield formelement:
drupal_get_form
<wbr>doesthe following:</wbr>
<wbr></wbr>
- Starts the entire form-building process by gettingthe<wbr><code style="border:0px; background-color:rgb(246,246,242); font-size:0.923em; margin:0px; padding:1px; vertical-align:baseline; font-family:'Bitstream Vera sans Mono',Monaco,'Lucida Console',monospace; line-height:1.5em; white-space:pre-wrap">$form</code><wbr>fromthe builder function</wbr></wbr>
- Translates the<wbr><code style="border:0px; background-color:rgb(246,246,242); font-size:0.923em; margin:0px; padding:1px; vertical-align:baseline; font-family:'Bitstream Vera sans Mono',Monaco,'Lucida Console',monospace; line-height:1.5em; white-space:pre-wrap">$form['name']</code><wbr>itemsinto actual form elements</wbr></wbr>
- Performs any validation and "clean-up" that needs to be done, andcalls custom validation functions if declared
- Submits the form if a submit function is declared, and the form hasbeen submitted
- Calls any custom theming functions that have been declared
- Returns an HTML string which contains the actual form.
type=> 'submit'
<wbr>willbe passed to their corresponding submit function if it isavailable. This method is more secure thangrabbing<wbr></wbr></wbr>
$_POST['edit']
<wbr>andusing a switch statement.</wbr>