[support] ahah question - adding new form elements

Ámon Tamás amont at 5net.hu
Fri Aug 15 14:57:28 UTC 2008


Hello,

This is my code:
function atleta_rankings_by_region_form($context) {
  $form['region'] = array(
   '#type' => 'select',
   '#title' => t('Select region'),
   '#options' => array(
     '' => '',
     'area' => t('Area'),
     'national' => t('National'),
     'games' => t('Games & Cups'),
     'event' => t('Custom region')
   ),
   '#ahah' => array(
      'path' => 'atleta/rankings_by_region/ahah',
      'wrapper' => 'atleta-ahah-wrapper',
      'method' => 'replace',
      'effect' => 'fade'),
  );
  $form['markup'] = array(
    "#value" => '<div id="atleta-ahah-wrapper"></div>'
  );
function atleta_rankings_by_region_ahah() {
  switch ( $_POST['region'] ) {
    case 'area':
      $form['area'] = array(
        '#type' => 'select',
        '#title' => t('Select region'),
        '#options' => array(
          '' => '',
          '1' => 'Europe',
          '2' => 'Asia',
          '3' => 'Rest of the word'
        ),
        '#required' => TRUE
      );
      $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Select by Area'),
        '#weight' => 100
      );
      $output = drupal_render($form);
      break;
}
drupal_json(array('status' => TRUE, 'data' => $output));
}

I get the new form elements in the wrapper, but when I press the submit 
button, my atleta_rankings_by_region_form_submit and 
atleta_rankings_by_region_form_validate is not running. What I must to 
do for it?

Ámon Tamás
Sitefejlesztő és programozó
-- 
5NET Informatikai Kft.
1062 Budapest, Aradi utca 38. A 3/11
telefon: (1) 461-0205  |  fax: (1) 461-0206
e-mail: amont at 5net.hu  |  web: http://www.5net.hu 



More information about the support mailing list