Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function my_ajax_menu() {
- $items = array();
- $items['admin/config/my_ajax_learning'] = array(
- 'title' => t('my ajax learning'),
- 'page callback' => 'my_ajax_form',
- 'access callback' => true,
- 'menu_name' => 'management',
- );
- return $items;
- }
- function my_ajax_form() {
- return drupal_get_form('ajax_form_b');
- }
- function ajax_form_b($form_id, $form_state) {
- $form = array();
- $form['my_learning_fieldset'] = array(
- '#type' => 'fieldset',
- '#title' => t('learning ajax'),
- '#description' => t('my learning ajax field set description'),
- '#tree' => true,
- );
- $form['my_learning_fieldset'][my_learning_checkbox'] = array(
- '#type' => 'radios',
- '#title' => t('learning ajax'),
- '#description' => t( 'learning ajax again'),
- '#options' => array(
- 'a' => 'a',
- 'b' => 'b',
- 'c' => 'c',
- ),
- '#ajax' => array(
- 'callback' => 'learn_ajax_here',
- 'wrapper' => 'put_ajax_here'
- ),
- );
- $form['my_ajax_content'] = array(
- '#type' => 'textfield',
- '#prefix' => '<div id = \'put_ajax_here\'>',
- '#suffix' => '</div>',
- '#description' => 'thank you',
- );
- return $form;
- }
- function learn_ajax_here($form, &$form_state) {
- drupal_set_message('<pre> ' . print_r($form_state['values'], true) . '</pre>');
- $form['test'] = array(
- '#title' => t('test'),
- '#description' => t('test'),
- '#type' => 'select',
- '#options' => $form_state['values']['my_learning_checkbox'],
- );
- return $form['test'];
- }
Add Comment
Please, Sign In to add comment