Advertisement
xandeadx

Untitled

Aug 26th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. function helper_menu() {
  2.   $items['test'] = array(
  3.     'title' => 'test',
  4.     'page callback' => 'helper_page_forms',
  5.     'access arguments' => array('access content'),
  6.   );
  7.   return $items;
  8. }
  9.  
  10. function helper_page_forms() {
  11.   $build['form1'] = drupal_get_form('helper_form1');
  12.   $build['form2'] = drupal_get_form('helper_form2');
  13.   return $build;
  14. }
  15.  
  16. function helper_form1($form, &$form_state) {
  17.   $form['submit'] = array(
  18.     '#type' => 'submit',
  19.     '#value' => 'Submit 1',
  20.     '#ajax' => array(
  21.       'callback' => 'helper_form1_ajax',
  22.     ),
  23.   );
  24.   return $form;
  25. }
  26.  
  27. function helper_form2($form, &$form_state) {
  28.   $form['submit'] = array(
  29.     '#type' => 'submit',
  30.     '#value' => 'Submit 2',
  31.     '#ajax' => array(
  32.       'callback' => 'helper_form2_ajax',
  33.     ),
  34.   );
  35.   return $form;
  36. }
  37.  
  38. function helper_form1_ajax() {
  39.   return array(
  40.     '#type' => 'ajax',
  41.     '#commands' => array(
  42.       ajax_command_alert('ajax 1'),
  43.     ),
  44.   );
  45. }
  46.  
  47. function helper_form2_ajax() {
  48.   return array(
  49.     '#type' => 'ajax',
  50.     '#commands' => array(
  51.       ajax_command_alert('ajax 2'),
  52.     ),
  53.   );
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement