GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Thursday, February 17, 2011

Drupal Form

When you code for drupal form, it's rather feel complicated. But it's simple enough to build what you want.
The procedures are:
1. Build your hook_menu to call the page that contain the form. In the hook_menu implementation, you need supply at least
a. title
b. page callback - for form, this is default to drupal_get_form
c. page argument - the function name you write inside array. This function implements drupal form
d. access callback - set to TRUE so averyone can access it

2. Build your form function
a. Insert in the arguments of the function definition: $form and &$form_state
b. define what form elements you provide

The list of the form elements:
a. submit: '#type' => 'submit', '#value' => 'Save'
b. item - provide small description '#type' => 'item', '#title' => t('The description')
c. textfield: '#type' => 'textfield', '#title' => t('The title'),
For more info, see code repositories
Share/Bookmark

No comments:

Post a Comment