I created a form in Drupal 7 and want to use AJAX. I added this to the submit button array:
"#ajax" => array(
"callback" => "my_callback",
"wrapper" => "details-container",
"effect" => "fade"
)
This works but the whole validation function is ignored. How can I validate the form before my_callback()
is called? And how can I display the status or error messages on a AJAX form?
Ok, I figure it out. Apparently you should return an array on your ajax callback function, not just a text message...
Something like this:
return array("#markup" => "<div id='wrapper'></div>");