July 2017
Intermediate to advanced
456 pages
11h 32m
English
In Drupal 7, a form was a function that returned an array containing nested elements from the Form API. Then, you would add appropriate _validate and _submit functions to handle verifying the submission and to handle the completed form in a simple case that would look as follows:
function my_module_my_form($form, &$form_state) $form['first'] = array( '#type' => 'textfield', '#title' => t('First name'), '#required' => TRUE, ); $form['last'] = array( '#type' => 'textfield', '#title' => t('Last name'), '#required' => TRUE, ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Submit', ); return $form; } function my_module_my_form_validate($form, &$form_state) { // Handle form validation } function my_module_my_form_submit($form, ...Read now
Unlock full access