With the code below I managed to alert the message but after that the form does not work properly, after the submit it redirects me to $base_url/system/ajax and a json array is displayed.
$form['submitted']['test']['#ajax'] = array ( 'callback' => '_test', 'wrapper' => 'nimportequi', 'progress' => array('type' => 'throbber', 'message' => '') );
and the callback:
function _test($form, $form_state){ $commands = array(); $text = ""; $alert = 0; if (valid_email_address($form['submitted']['email']['#value']) !== FALSE) { $result = user_load_by_mail($form['submitted']['email']['#value']); $text = ($result !== FALSE)?$alert=1:"Based on your email, you are not a member yet!"; } else $text = "Based on your email, you are not a member!"; if ($alert != 1 && $form_state['values']['submitted']['member'] == 1) { $commands[]=ajax_command_alert($text); // $commands[] = ajax_command_data("#foo", 'label_radio', '1'); } $form_state['rebuild'] == TRUE; return array('#type' => 'ajax', '#commands' => $commands); }
Also i am using a rule when the form is submitted. What am i doing wrong ? I cannot figure it out…