Hi everyone,

I've been at this for 2 days now to no avail, so I figured I'd enlist some help from the community.

I have a custom panels content type, for which I have a configuration form. The form has a dropdown, and that dropdown has an '#ahah' event:

When the '#ahah' event is called, I want a new set of dropdowns to come in, depending on which is selected in the ahah dropdown. I've followed steps outlined in http://drupal.org/node/331941, and I've made the necessary switch from drupal_ form funtions to ctools_ form functions per patch #831922: ctools wizard forms don't support standard drupal 'ahah' callbacks. I've tried nearly everything at this point, and can't seem to make this work properly. Here is the code:

AHAH Callback:
Note: The commented out items were all uncommented at one point and ive tested with lots of different combinations for them. They're commented here because this is my latest attempt.

$form_state = array(
        'storage' => NULL,
        'rebuild'=>TRUE,
        'rerender'=>FALSE,
        'submitted'=>NULL,
        'wrapper callback'=>'ctools_wizard_wrapper',
        'no_redirect'=>TRUE,
        'step'=>'form',
        'want form'=>TRUE, //return the form (from ctools form.inc)
        //'form_info'=>NULL,
    );
    $form_build_id = $_POST['form_build_id'];
    //$form = form_get_cache($form_build_id, $form_state);
    //$form_debug = $form;
    //$args = $form['#parameters']; //this is empty at this point so why set it?
    $form_id = $_POST['form_id'];
    //$form['#post'] = $_POST;
    //$form['#redirect'] = FALSE;
    //$form['#programmed'] = FALSE;
    $form_state['input'] = $_POST;
    
    ctools_include('form');

    //ctools_process_form($form_id, $form, $form_state);
    //$form = ctools_rebuild_form($form_id, $form_state, $args, $form_build_id);
    $form = ctools_build_form($form_id, $form_state);
    
    //HERE is where i SHOULD be extracting from the built $form but since its empty
    //I tried using the original function. No dice. They come back with no defaults set
    //and no name or id in the markup, as if the form has disowned them
    $my_header_form = array();
    $form += my_header_form_selects($state, array());

    $output = theme('status_messages').drupal_render($my_header_form);

    drupal_json(array('status' => TRUE, 'data' => $output));

The edit form in MY_PLUGIN_content_type_edit_form()

$form['header_state'] = array(
      '#type' => 'select',
      '#title' => t('Select the Header State'),
      '#default_value' => $conf['header_state'],
      '#options' => $options,
      '#description' => t('Select the state of the Masthead.'),
      '#attributes' => array('style' => 'width:650px;'),
      '#weight' => 1,
      '#ahah' => array(
        'path' => 'my_module/js',
        'wrapper' => 'masthead-options',
        'method' => 'replace',
        'effect' => 'fade',
      ),
  );
  
  $form['options-div-open'] = array ('#value' => '<div id="masthead-options" name="masthead-options">', '#weight'=>5);

  //build the current options form from the state config
  $form += my_header_form_selects($my_states[$conf['header_state']], $conf);


  //close options
  $form['options-div-close'] = array ('#value' => '</div>', '#weight'=>100);

In the examples, it would appear that the $form is supposed to rebuild itself with the new elements which I can then pick out of the $form array and return in my AHAH call. When it get's down to returning the content the $form array no longer contains the form elements. It looks more like it's been processed. I tried calling the function that builds the particular part of the form, and that works fine, but when the form elements come back no default values are loaded, and the id and name properties of the HTML form elements are all empty, as if they are not related to the form at all.

If anyone has any insight on how to correctly do this, I would greatly appreciate your help.

Thanks,
M.

Comments

memyselfandm’s picture

Another note: when the blank form items are returned, the "finish" and "cancel" buttons no longer work. They either do nothing, or cause the modal to go empty and not close.

rafalenden’s picture

Did you found solution for this problem?

joelpittet’s picture

Status: Active » Closed (outdated)
Issue tags: -

Triaging the 6.x issues, it's no longer supported.