Guest User

Untitled

a guest
Jun 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. <?php
  2.  
  3. function my_ajax_menu() {
  4. $items = array();
  5.  
  6. $items['admin/config/my_ajax_learning'] = array(
  7. 'title' => t('my ajax learning'),
  8. 'page callback' => 'my_ajax_form',
  9. 'access callback' => true,
  10. 'menu_name' => 'management',
  11. );
  12.  
  13. return $items;
  14. }
  15.  
  16. function my_ajax_form() {
  17. return drupal_get_form('ajax_form_b');
  18. }
  19.  
  20. function ajax_form_b($form_id, $form_state) {
  21. $form = array();
  22.  
  23. $form['my_learning_fieldset'] = array(
  24. '#type' => 'fieldset',
  25. '#title' => t('learning ajax'),
  26. '#description' => t('my learning ajax field set description'),
  27. '#tree' => true,
  28. );
  29.  
  30. $form['my_learning_fieldset'][my_learning_checkbox'] = array(
  31. '#type' => 'radios',
  32. '#title' => t('learning ajax'),
  33. '#description' => t( 'learning ajax again'),
  34. '#options' => array(
  35. 'a' => 'a',
  36. 'b' => 'b',
  37. 'c' => 'c',
  38. ),
  39. '#ajax' => array(
  40. 'callback' => 'learn_ajax_here',
  41. 'wrapper' => 'put_ajax_here'
  42. ),
  43. );
  44.  
  45. $form['my_ajax_content'] = array(
  46. '#type' => 'textfield',
  47. '#prefix' => '<div id = \'put_ajax_here\'>',
  48. '#suffix' => '</div>',
  49. '#description' => 'thank you',
  50. );
  51.  
  52. return $form;
  53. }
  54.  
  55. function learn_ajax_here($form, &$form_state) {
  56. drupal_set_message('<pre> ' . print_r($form_state['values'], true) . '</pre>');
  57.  
  58. $form['test'] = array(
  59. '#title' => t('test'),
  60. '#description' => t('test'),
  61. '#type' => 'select',
  62. '#options' => $form_state['values']['my_learning_checkbox'],
  63. );
  64.  
  65. return $form['test'];
  66. }
Add Comment
Please, Sign In to add comment