I'm trying to replace messages from the Web Links module... But nothing happens... Can this module handle messages set by form_set_error()?

Comments

BartonDrupal’s picture

yeah, the message type is "error"

walker2238’s picture

Hmmm, that's odd then.

Maybe you can point out what I'm doing wrong.

function newslinks_message_alter(&$messages) {

  $matches = $messages->contains('required');

  if ($matches) {
    $messages->remove($matches);  
    $messages->add('Testing, testing, 1, 2, 3.');  
  }
}
thedavidmeister’s picture

Category: feature » support

This is a support request... also, should we really be using the issue queue for a specific module for general php coding advice?

looking in the MessagesAlter class it appears you should be using $messages->contains('required', 'error'); if you just want to test errors only.

also, i'm not sure if this would help because I haven't tested your code, but I personally would test if( !empty($matches) ) rather than just if( $matches ), just to be safe.

BartonDrupal’s picture

Status: Active » Fixed
thedavidmeister’s picture

what i suggested with !empty... do this instead:


  $matches = $messages->contains('check something');

  if( $matches !== FALSE ) {
    /* do something */
  }

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.