I created a module to hook the webform using the hook_form_alter.This converted the webform into AJAX form. This worked on localhost . But when I installed the same module to web server , it does not work.
This is the main code part of the module.
function alterwebform_form_alter(&$form, &$form_state, $form_id) {
if(strstr($form_id, 'webform_client_form_')) {
$nid = $form['#node']->nid;
$form['actions']['submit']['#ajax'] = array(
'callback' => 'alterwebform_webform_js_submit',
'wrapper' => 'webform-client-form-' . $nid,
'method' => 'replace',
'effect' => 'fade',
);
}
$form['actions']['submit']['#validate']= array('alterwebform_ajax_myform_validate');
}
//this is the callback function.
function alterwebform_webform_js_submit($form, $form_state) {
$sid = $form_state['values']['details']['sid'];
if ($sid) {
$node = node_load($form_state['values']['details']['nid']);
$confirmation = array(
'#type' => 'markup',
'#markup' => check_markup($node->webform['confirmation'], $node->webform['confirmation_format'], '', TRUE),
);
return $confirmation;
}
else {
return $form;
}
}
Any hint or suggestion please . Thank you .