multiform_test.module

Tracking master branch
  1. drupal
    1. 7 contributions/multiform/tests/multiform_test.module

@author Kálmán Hosszu - http://drupal.org/user/267481

Functions & methods

NameDescription
multiform_test1_1Build multiform_test1_1 form.
multiform_test1_2Build multiform_test1_2 form.
multiform_test1_delete_buttonHandling delete.
multiform_test1_submit_buttonSubmit handing.
multiform_test2_1Build multiform_test2_1 form.
multiform_test2_2Build multiform_test2_2 form.
multiform_test2_submit_buttonSubmit handing.
multiform_test_menuImplementation of hook_menu().

File

View source
  1. <?php
  2. /**
  3. * @file
  4. *
  5. *
  6. *
  7. * @author Kálmán Hosszu - http://drupal.org/user/267481
  8. */
  9. /* ====================== */
  10. /* ==== DRUPAL HOOKS ==== */
  11. /* ====================== */
  12. /**
  13. * Implementation of hook_menu().
  14. *
  15. * @return An array of menu items.
  16. */
  17. function multiform_test_menu() {
  18. $items = array();
  19. $items['multiform-test/1'] = array(
  20. 'title' => 'Multiform test page 1',
  21. 'page callback' => 'multiform_get_form',
  22. 'page arguments' => array(array('multiform_test1_1'), array('multiform_test1_2')),
  23. 'access callback' => TRUE,
  24. 'type' => MENU_CALLBACK,
  25. );
  26. $items['multiform-test/2'] = array(
  27. 'title' => 'Multiform test page 2',
  28. 'page callback' => 'multiform_get_form',
  29. 'page arguments' => array(array('multiform_test2_1'), array('multiform_test2_2')),
  30. 'access callback' => TRUE,
  31. 'type' => MENU_CALLBACK,
  32. );
  33. return $items;
  34. }
  35. /* ====================== */
  36. /* == MODULE FUNCTIONS == */
  37. /* ====================== */
  38. /* FIRST TEST CASE */
  39. /**
  40. * Build multiform_test1_1 form.
  41. *
  42. * @param type $form
  43. * @param type $form_state
  44. * @return array
  45. */
  46. function multiform_test1_1($form, $form_state) {
  47. $form['submit'] = array(
  48. '#type' => 'submit',
  49. '#value' => 'save',
  50. '#submit' => array('multiform_test1_submit_button'),
  51. );
  52. $form['delete'] = array(
  53. '#type' => 'submit',
  54. '#value' => 'delete',
  55. '#submit' => array('multiform_test1_delete_button'),
  56. );
  57. return $form;
  58. }
  59. /**
  60. * Build multiform_test1_2 form.
  61. *
  62. * @param type $form
  63. * @param type $form_state
  64. * @return string
  65. */
  66. function multiform_test1_2($form, $form_state) {
  67. $form['submit'] = array(
  68. '#type' => 'submit',
  69. '#value' => 'save',
  70. '#submit' => array('multiform_test1_submit_button'),
  71. );
  72. $form['delete'] = array(
  73. '#type' => 'submit',
  74. '#value' => 'delete',
  75. '#submit' => array('multiform_test1_delete_button'),
  76. );
  77. return $form;
  78. }
  79. /**
  80. * Submit handing.
  81. *
  82. * @param type $form
  83. * @param type $form_state
  84. */
  85. function multiform_test1_submit_button($form, $form_state) {
  86. drupal_set_message($form['#form_id'] . 'multiform_test1_submit_button');
  87. }
  88. /**
  89. * Handling delete.
  90. *
  91. * @param type $form
  92. * @param type $form_state
  93. */
  94. function multiform_test1_delete_button($form, $form_state) {
  95. drupal_set_message($form['#form_id'] . 'multiform_test1_delete_button');
  96. }
  97. /* SECOND TEST CASE */
  98. /**
  99. * Build multiform_test2_1 form.
  100. *
  101. * @param type $form
  102. * @param type $form_state
  103. * @return array
  104. */
  105. function multiform_test2_1($form, $form_state) {
  106. $form['required_text_1'] = array(
  107. '#type' => 'textfield',
  108. '#title' => 'test1',
  109. '#required' => TRUE,
  110. );
  111. $form['submit'] = array(
  112. '#type' => 'submit',
  113. '#value' => 'save',
  114. '#submit' => array('multiform_test2_submit_button'),
  115. );
  116. return $form;
  117. }
  118. /**
  119. * Build multiform_test2_2 form.
  120. *
  121. * @param type $form
  122. * @param type $form_state
  123. * @return array
  124. */
  125. function multiform_test2_2($form, $form_state) {
  126. $form['required_text_2'] = array(
  127. '#type' => 'textfield',
  128. '#title' => 'test2',
  129. '#required' => TRUE,
  130. );
  131. $form['submit'] = array(
  132. '#type' => 'submit',
  133. '#value' => 'save',
  134. '#submit' => array('multiform_test2_submit_button'),
  135. );
  136. return $form;
  137. }
  138. /**
  139. * Submit handing.
  140. *
  141. * @param type $form
  142. * @param type $form_state
  143. */
  144. function multiform_test2_submit_button($form, $form_state) {
  145. drupal_set_message($form['#form_id'] . 'multiform_test2_submit_button');
  146. }