Form API skeleton

Public

Get raw version
php
  1. /**
  2.  * Implements hook_menu()
  3.  */
  4. function mymodule_menu() {
  5. $items = array();
  6.  
  7. $items['admin/config/../..'] = array(
  8. 'title' => '',
  9. 'type' => MENU_NORMAL_ITEM,
  10. 'page callback' => 'drupal_get_form',
  11. 'page arguments' => array('…_form'),
  12. 'access arguments' => array('...'),
  13. );
  14.  
  15. return $items;
  16. }
  17.  
  18.  
  19. function …_form($form, &$form_state) {
  20. $form = array();
  21.  
  22. $form['…'] = array(
  23. '#type' => 'fieldset',
  24. '#collapsible' => FALSE,
  25. '#title' => t('...'),
  26. '#description' => t('...'),
  27. );
  28.  
  29. $form['… ']['…'] = array(
  30. '#type' => 'textfield',
  31. '#title' => t(''),
  32. '#description' => t('... !n …', array('!n' => )),
  33. '#default_value' => variable_get('', ),
  34. '#required' => TRUE
  35. );
  36.  
  37. $form['… ']['…'] = array(
  38. '#title' => '...',
  39. '#description' => t(''),
  40. '#type' => 'select',
  41. '#options' => array(
  42. '...' => t('...'),
  43. '...' => t('...'),
  44. ),
  45. '#default_value' => variable_get('...', '...'),
  46. );
  47.  
  48. $form['…']['…'] = array(
  49. '#type' => 'radios',
  50. '#required' => TRUE,
  51. '#default_value' => ...,
  52. );
  53.  
  54. $form['…']['…'] = array(
  55. '#type' => 'item',
  56. '#markup' => t('..%item..', array('%item' => ..)),
  57. );
  58.  
  59. return system_settings_form($form);
  60. }
  61.  
  62. function …_form_validate($form, &$form_state) {
  63.  
  64. if (...) {
  65. form_set_error('', t(''));
  66. }
  67. }
  68.  
  69.  
  70. function …_form_submit($form, &$form_state) {}