I'm making multistep modal form by following the example in ctools_ajax_sample.module.
I'm not seeing any Next/Cancel buttons added to my form, nor do I see the trail; None of the form components added in the ctools_wizard_wrapper() wrapper_callback are added to my form, despite the $form_info I'm passing to ctools_wizard_multistep_form() being (apparently) correct. Dumping $form immediately after calling ctools_wizard_multistep_form($form_info, $step, $form_state) in my code shows no buttons or ctools_trail, but it does in the example code.

Here's my definition of $form_info:

  $form_info = array(
    'id' => 'create_ticket',
    'path' => "support/" . ($js ? 'ajax' : 'nojs') . "/modal/%step",
    'show trail' => TRUE,
    'show back' => TRUE,
    'show cancel' => TRUE,
    'show return' => FALSE,
    'next callback' => 'create_ticket_next',
    'finish callback' => 'create_ticket_finish',
    'cancel callback' => 'create_ticket_cancel',
    
    'order' => array(
      'select_site' => t('Select a site'),
      'ticket' => t('Create a ticket'),
    ),
    'forms' => array (
      'select_site' => array(
        'form id' => 'select_site_form',
      ),
      'ticket' => array(
        'form id' => 'parature_ticket_form',
      ),
    ),
  );

And here's where I call ctools_wizard_multistep_form, which doesn't include the multistep form buttons and trail (unlike in the example). Instead, the result is just the plain form as defined in the function that defines it.

  $form = ctools_wizard_multistep_form($form_info, $step, $form_state);
  $output = drupal_render($form);

I have confirmed that the wrapper_callback, ctools_wizard_wrapper (which is supposed to add these elements to the form), is being called. But nothing is added to the form.

Comments

nagiek’s picture

does it work when it's not in the modal?

Larksmann’s picture

No - no trail or buttons show either way.

nagiek’s picture

Component: Modal » Code

Post your form - you may be overriding $form['buttons']

Larksmann’s picture

I don't think that's the issue. Even if I was, I'm certainly not overriding $form['ctools_trail']. Currently the first form is really simple:

function select_site_form($form, &$form_state) {
  $form_state['title'] = t('Select a site');
  return array(
    'site' => array(
      '#title' => 'Site',
      '#type' => 'textfield',
      '#description' => t('Which site do you need help with?'),
    ),
  );
}
merlinofchaos’s picture

In Drupal 7 you must return $form. I bet that's your problem.

merlinofchaos’s picture

Status: Active » Fixed

And by that I mean, the $form coming IN already has those elements. You are returning array() and ignoring what was sent to you. I'm 100% sure that is your problem.

Instead you should do


$form['site'] =    array(
      '#title' => 'Site',
      '#type' => 'textfield',
      '#description' => t('Which site do you need help with?'),
  );
Larksmann’s picture

Of course! Thank you so much merlinofchaos - I can't believe how many hours I spent trying to track down the issue. I feel a little dumb now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.