Could someone deliver a simple (working) example ?

Events happening in the community are now at Drupal community events on www.drupal.org.
EDDYL's picture

I did not manage to get the ajax module working ; maybe due to the absence of documentation.. Who knows ? ;-) LOL

Here is my actual code :

function test_ajax_form_admin() {

   $form['input'] = array(
      '#type' => 'textfield',
     '#title' => 'mon parametre',
        '#description' => 'decription détaillée',
     '#validations' => array(
          'required' => array(
              'value' => TRUE,
              'message' => 'Please enter something in %field_title',
              ),
         'type' => number,
         'min' => 0, // for checkboxes or multiple select, min number selected
         'max' => 10,
          ),
        );
  $form['input2'] = array(
     '#type' => 'textfield',
     '#title' => 'mon 2nd paramètre',
     '#description' => 'decription détaillée 2',
       '#validations' => array(
          'required' => array(
              'value' => TRUE,
              'message' => 'Please enter something in %field_title',
              ),
         'type' => number,
         'min' => 0, // for checkboxes or multiple select, min number selected
         'max' => 100,
         ),
);


//  return system_settings_form($form);

    return $form;

}

I tried this code :

in a page (with PHP activated),

in a test module (with return $form or with return system_settings_form($form),

with

$form['my_submit'] = array(
      '#type' => 'submit',
    '#ajax' => array(
       'submitter' => TRUE
     ),
     '#value' => t('My Own Submit Button')
);

or with

'#ajax' => array(
           'submitter' => TRUE
           ),

as well as with

$form['#ajax'] = array(
            'enabled' => TRUE
      );

and nothing worked.

Do we need to use the hooks provided by the API, and if so how should we use them ?

If you've succeded in using this module (and I am sure some people did), thanks for giving a simple example of code that could be a base to start for others.

Edouard

Ajax.module

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: