Comments

robin van emden’s picture

Thanks for this module! I like the idea of the suggested feature. The order can be changed for all forms by changing the order of elements in an ife-form-element.tpl.php override, but setting this by form in the admin section makes sense to me.

stijndm’s picture

I'll have a look in to this, but this will require an override of the core theme_form_element function which could lead to conflicts with other contributed modules and themes.

stijndm’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
stijndm’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
stijndm’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
robertom’s picture

Hi, sorry for my bad english.

If could be helpful for someone, I've used a dirty workaround for add error inside the "wrapper" of fields (useful when is used a based grid theme).

inside template.php of my theme, I've added this code:


/**
 * OVERRIDE theme_ife_form_element();
 * 
 * Theme the form element, add the error, when one occured.
 */
function mytheme_ife_form_element($variables) {
  $output = '';
  $output = $variables['element']['#children'];

  if (isset($variables['element']['#id'])) {
    $error = ife_errors('get', $variables['element']['#id']);

    if (!empty($error)) {
      $error_element = '<div class="messages error messages-inline">' . $error . '</div>';
      
      $pos = strpos($output, ">");
      if ($pos !== FALSE) {
        $output = substr_replace($output, $error_element, $pos + 1, 0);
      } else {
        $output .= $error_element;
      }
    }
  }
  return $output;
}

obviously you need to replace mytheme with the name of your theme

d.clarke’s picture

For what it is worth, I accomplished a similar goal by overriding theme_ife_form_element to just return the $variables['element']['#children'] value and then moving the ife_errors() call and the output to theme_form_element per stijndm.

skaught’s picture

Issue summary: View changes

i use this to get the messages into the end of the 'form-item'...

function theme_ife_form_element($variables) {
  $output = '';
  $output = $variables['element']['#children'];

  if (isset($variables['element']['#id'])) {
    $error = ife_errors('get', $variables['element']['#id']);

    if (!empty($error)) {
      $error_wrapped = '<div class="messages error messages-inline">' . $error . '</div>';	
      $output =   preg_replace('#(.*)(</[a-z]+>)#si', '$1' . $error_wrapped . '$2', $output);
      
    }
  }
  return $output;
}