drupal Form Properties
When building the function in your form to build a form definition, the array of keys is used to declare a form of information. The following section lists the commonly used keys. Some keys will be automatically added and built form.
The following section of the property-specific form. In other words, you can set $ form ['# programmed'] = TRUE, but if you set $ form ['myfieldset'] ['mytextfield'] [# programmed '] = TRUE then the form will not know your builder want it to do anything.
This property is an array containing the pass drupal_get_form () of the original parameters. By drupal_retrieve_form () can be added to the property.
This is a Boolean property to indicate a form is a way to process such as through drupal_execute () to submit. If you set the property before the form processing # post, you can use drupal_prepare_form () to set the property.
The property is a string (using MD5 hash). In the multi-step form, # build_id used to identify a specific form instance. It as a hidden field on the form, through the use of drupal_prepare_form () to set the form elements, as follows:
$ Form ['form_build_id'] = array (
'# Type' => 'hidden',
'# Value' => $ form ['# build_id'],
'# Id' => $ form ['# build_id'],
'# Name' => 'form_build_id',
This is an optional string attribute which if Drupal decides to call validation, submission, and theme function to use. Will be $ form ['# base'] is set to the prefix you want to use Drupal. For example, if you will be $ form ['# base'] set to 'foo', and calls drupal_get_form ('bar'), in bar_validate () and bar_submit () does not exist in the case, Drupal will use foo_validate () and foo_submit () as the processor. This property is also used to map the theme function. See drupal_render_form () ( http://api.drupal.org/api/5/function/drupal_render_form ).
The string (using MD5 hash) is a unique token, each form comes with it, through the token to determine a form Drupal is a true form and not a Drupal malicious user to modify after.
This property is a form_clean_id ($ form_id) the resulting string, and it is a HTML ID attribute. $ Form_id flip the bracket in any of "][", underscore "_" or a space character''will be replaced in order to generate consistent with the CSS ID.
The string property is the form tag action attribute. By default, it is request_uri () return value.
The string attribute refers to the form presented in a way --- usually post. API is based on the post form was constructed, it will not be processed using the GET method to submit the form. See the HTML specification on the part of the distinction between GET and POST. If you need to use the GET method, you may need to use Drupal's menu API, rather than the form API.
This property can be a string or an array. If the strings, then it is in the form is submitted after the user wants to redirect the Drupal path. If it is set to an array, the array will be passed to drupal_goto (), of which the first element of the array should be the target path (which will allow the drupal_goto () to pass additional parameters.)
This property is an array, which contains previously presented in the form function to call. Each contains the function to call $ form_id parameter and $ form. For example, setting # pre_render = array ('foo', 'bar') will lead to Drupal first call the function foo ($ form_id, $ form), and then call the bar ($ form_id, $ form). When you want to verify the completion of the form after the show before, the use of hooks to modify the form structure is very useful. If you want to modify the form validation before use hook_form_alter ().
Add to all elements and attributes
When the form builder build forms using the form definition, it needs to ensure that each form element should have some default settings. These default values in the includes / form.inc function _element_info () in the set, but can be hook_elements () in the definition of the form elements covered.
All form elements will add the string property, which defaults to NULL. The theme function through form elements to render it. For example, textfield description appears in the textfield below the input box, as shown in Figure 10-2.
All form elements will add the Boolean property, which defaults to FALSE. It is set to TRUE, if the form is submitted after the time the field is empty, Drupal built-in form validation will throw an error message. Also, if it is set to TRUE, then the form will set a CSS class element (see includes / form.inc in theme_form_element ())
All form elements will add the Boolean property, which defaults to FALSE. If it is set to TRUE, the form is submitted after the $ form_values array will be nested (rather than flat.) This will affect your access to submit data format. (See this chapter "field set (Fieldsets)" section).
The $ _POST array property of the original data, a copy of the form builder it will be added to all form elements. Thus, in the # process and # after_build defined functions can be based on the contents of # post to make intelligent decisions.
All form elements will be added to the array property, it defaults to an empty array. It is for internal use form builder to identify the parent tree form, form element node. For more information, see http://drupal.org/node/48643 .
All form elements will be added to the array property, it defaults to an empty array, but the theme function will gradually fill the array. Members of the array will be used as HTML attributes. For example, $ form ['# attributes'] = array ('enctype' => 'multipart / form-data').
Common form element attributes
This section explains the properties of all the form elements can be used.
This declares a string type of form element. For example, # type = 'textfield'. Declaration form must contain the root of # type = 'form'.
This Boolean property determines whether the form element visible to the user. If the form element has a child form elements, and if the parent form element # access property to FALSE, then the child form elements will not be displayed. For example, if a form element is a set of fields, and if it's # access to FALSE, then the field is set all the fields which are not shown.
This property is an associative array. Each item in the array, a function name as key, any parameter passed to the function as a value. When building the form element will call these functions, allowing form element in the building to add additional operations. For example, the definition of the checkboxes in the system.module type of form in the building during the call set includes / form.inc inside the function expand_checkboxes ():
$ Type ['checkboxes'] = array (
'# Input' => TRUE,
'# Process' => array ('expand_checkboxes' => array ()),
'# Tree' => TRUE);
See this chapter "to collect all the possible elements of the definition of the form" part of another example. # Process the array when all the functions are called, for each form element to add a # processed attribute.
This property is an array. Stored in an array constructed in the form elements you've got to call the function immediately. The function to be called each have two parameters: $ form and $ form_values. For example, if $ form ['# after_build'] = array ('foo', 'bar'), then the Drupal form element in the building after completion, were called foo ($ form, $ form_values) and bar ($ form, $ form_values). Once these functions are called after, Drupal for each form element in the internal add a # after_build_done property.
This optional attribute defines a string, when the Drupal theme function for the form elements to find the time to use it. For example, setting # theme = 'foo', will make Drupal calls theme_get_function ('foo', $ element), the function will be in accordance with the sequential search function themename _foo (), themeengine _foo (), and theme_foo (). See earlier in this chapter "for the form to find the theme function" section.
This property is a string rendered in the form elements will be added to the front of the form elements.
This property is a string rendered in the form elements will be added to the back of the form elements.
The string is the title form elements.
The property can be an integer or a fraction. When rendering the form element, it will be sorted according to their weight. Small weight will be put in front of the elements, heavy elements will be placed below the page positions.
The type of the property according to the type of form element. For the input form elements, if the form has not been submitted, then it is the value used in the field. Do it in the form element # value confusion. # Value form element defines the value of an internal form, the user can not see the value, but it is defined in the form and appear in the $ form_values.