Commit a8126de8 authored by John Franklin's avatar John Franklin
Browse files

Clean up the AHAH selection of type.

parent af67771d
Loading
Loading
Loading
Loading
+10 −8
Changes for ad.module: 10 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -647,14 +647,10 @@ function ad_form(&$node, &$form_state) {
      '#required' => TRUE,
      '#options' => $adtypes,
      '#default_value' => isset($node->adtype_select) ? $node->adtype_select : '',
    );
    $form['select']['adtype_submit'] = array(
      '#type' => 'submit',
      '#value' => t('Select'),
      '#validate' => array('ad_select_adtype'),
      '#ahah' => array(
        'path' => 'node/add/ad/ahah',
        'wrapper' => 'adtype-ahah-wrapper',
        'effect' => 'slide',
      ),
    );
  }
@@ -815,9 +811,12 @@ function ad_select_adtype(&$form, &$form_state) {
 * Ad type switch AHAH menu handler.
 */
function ad_form_ahah() {
  $form_state = array('storage' => NULL, 'submitted' => FALSE);
  $form_state = array('submitted' => FALSE);
  $form_build_id = $_POST['form_build_id'];
  $form = form_get_cache($form_build_id, $form_state);
  if (!$form = form_get_cache($form_build_id, $form_state)) {
    exit;
  }
  
  ad_form_add_adtype_elements($form, $_POST['adtype_select']);
  form_set_cache($form_build_id, $form, $form_state);
  $form += array(
@@ -826,7 +825,10 @@ function ad_form_ahah() {
  );
  // Rebuild the form.
  $form = form_builder($_POST['form_id'], $form, $form_state);
  $output = drupal_render($form['adtype_elements']);
  
  $option_form = $form['adtype_elements'];
  unset($option_form['#prefix'], $option_form['#suffix']);
  $output = drupal_render($option_form);
  drupal_json(array(
    'status'   => TRUE,
    'data'     => $output,