I have a form generated via the form api with a validate and submit function. On validation if fields fail validation then form_set_error is called.

This work fine when the form is not linked to popups, however when it is linked the error messages are no longer displayed.

How do I get these message to appear?

Comments

gony’s picture

Note: I have also tried adding the popup class to a link to /contact and I still get the same problem.

flahertypj’s picture

I'm wondering the same as gony.

Thanks
Patrick

operations’s picture

Same here !! I'm begining to hate this module ! why the form submission errors not appearing by default in the popups module?? Isn't this supposed to be a normal feature as this module is used widely for webforms.

Anyone has solved this issue ?

:(

wowik73’s picture

i create node-webform.tpl.php and add text

if (isset($GLOBALS['_SESSION']['messages']['error'])) {
$messages = $GLOBALS['_SESSION']['messages']['error'];
echo '

    ';
    foreach($messages as $key => $value) {
    echo '
  • '.$value.'
  • ';
    unset($GLOBALS['_SESSION']['messages']['error'][$key]);
    }
    echo '

';
}

if (isset($GLOBALS['_SESSION']['messages']['status'])) {
$messages = $GLOBALS['_SESSION']['messages']['status'];
echo '

    ';
    foreach($messages as $key => $value) {
    echo '
  • '.$value.'
  • ';
    unset($GLOBALS['_SESSION']['messages']['status'][$key]);
    }
    echo '

';
}

operations’s picture

Ya wowik73, this might work.

But I had to fix it in the popups module itself to work for me as below:

in popups.module line 128 popups_render_as_json function:

before

/**
 * Render the page contents in a custom json wrapper.
 *
 * @param $content: themed html.
 * @return $content in a json wrapper with metadata.
 */
function popups_render_as_json($content) {
  // Call theme_page so modules like jquery_update can do their thing. We don't
  // really care about the mark up though.
  $ignore = theme('page', $content);

  $path = $_GET['q']; // Get current path from params.
  return drupal_json(array(
    'title' => drupal_get_title(),
    'messages' => theme('status_messages'),
    'path' => $path,
    'content' => $content,
    'js' => popups_get_js(),
    'css' => popups_get_css(),
  ));
}

after

/**
 * Render the page contents in a custom json wrapper.
 *
 * @param $content: themed html.
 * @return $content in a json wrapper with metadata.
 */
function popups_render_as_json($content) {
  // Call theme_page so modules like jquery_update can do their thing. We don't
  // really care about the mark up though.
  $ignore = theme('page', $content);

  $path = $_GET['q']; // Get current path from params.
  
  /* Fix bug: No form submission errors appear on tellafriend, contact us.
  */
  $form_errors = form_get_errors();
  if(isset($form_errors))
  {
  	$f = '<div class="messages error"><ul>';
  	foreach ($form_errors as $error)
  	{
  		$f .= '<li>'.$error.'</li>';
  	}
  	$f .= '</ul></div>';
  }
  /*******************************/
  
  return drupal_json(array(
    'title' => drupal_get_title(),
    'messages' => theme('status_messages'),
    'path' => $path,
    'content' => $f.$content,
    'js' => popups_get_js(),
    'css' => popups_get_css(),
  ));
}