Actually i want to redirect to some other page after submitting the multistep ctools modal form .I have tried using form_state['redirect] and drupal_goto in submit function but didnt work.
function get_quote_menu(){
$items=array();
$items['get_quote'] = array(
'title' => 'Get Quotation',
'page callback' => 'get_quote_form',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['get_quote/%ctools_js/details'] = array(
'title' => 'Get Quotation',
'page callback' => 'quote_ajax_details_form',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
function quote_ajax_details_form($js = NULL, $step = NULL){
if ($js) {
ctools_include('modal');
ctools_include('ajax');
}
$form_info=array(
'id' => 'quote_details',
'path' => "get_quote/" . ($js ? 'ajax' : 'nojs') . "/details/%step",
'show trail' => TRUE,
'show back' => TRUE,
'show cancel' => TRUE,
'show return' => FALSE,
'next callback' => 'get_quote_details_next',
'finish callback' => 'get_quote_details_finish',
'cancel callback' => 'get_quote_details_cancel',
'order' => array(
'start' => t('View the plans and premiums best suited to you <br/>in 4 straight forward steps.'),
'second'=>t(''),
),
'forms' => array(
'start' => array(
'form id' => 'get_quote_start',
),
'second'=>array(
'form id'=> 'get_actual_quote_details',
)
),
);
$object_id = 1;
if (empty($step)) {
// We reset the form when $step is NULL because that means they have
// for whatever reason started over.
get_quote_cache_clear($object_id);
$step = 'start';
}
// This automatically gets defaults if there wasn't anything saved.
$object = get_quote_cache_get($object_id);
$form_state = array(
'ajax' => $js,
// Put our object and ID into the form state cache so we can easily find
// it.
'object_id' => $object_id,
'object' => &$object,
);
ctools_include('wizard');
$form = ctools_wizard_multistep_form($form_info, $step, $form_state);
$output = drupal_render($form);
if($js){
$commands=array();
if($output===FALSE || !empty($form_state['complete'])){
$commands[] = ajax_command_html('#ctools-sample', finish($form_state['object']));
$commands[] = ctools_modal_command_dismiss();
}else if(!empty($form_state['cancel'])) {
$commands[] = ctools_modal_command_dismiss();
}else {
$commands = ctools_modal_form_render($form_state, $output);
}
print ajax_render($commands);
exit;
}else{
return $output;
}
}
function get_quote_start($form, &$form_state){
$form['first_name'] = array(
'#title' => t('Your Name'),
'#type' => 'textfield',
'#size'=>20,
'#default_value' => $form_state['object']->first_name,
'#attributes'=>array(
'placeholder'=>t('First Name'),
'id'=>array('quote-first-name'),
),
//'#required'=>true,
);
$form['middle_name'] = array(
'#type' => 'textfield',
'#default_value' => $form_state['object']->middle_name,
'#size'=>20,
'#attributes'=>array(
'placeholder'=>t('Middle Name'),
'id'=>array('quote-middle-name'),
),
//'#required'=>true,
);
return $form;
}
function get_quote_start_submit(&$form, &$form_state){
global $user;
$form_state['object']->uid=$user->uid;
}
function get_actual_quote_details($form, &$form_state){
$form['adults']=array(
'#type'=>'select',
'#title' => t('Adults'),
'#options'=>array(
1=>1,
2=>2,
3=>3,
),
);
return $form;
}
function get_actual_quote_details_submit(&$form, &$form_state){
// Not working redirect
// drupal_goto('node/add/page');
$form_state['redirect]='node/add/page',
}