The "Custom error message" field does not seem to support tokens.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sano created an issue. See original summary.

sano’s picture

patch for the issue

sano’s picture

Another patch to fix the i18n issue when translating the error message.

alexh’s picture

Category: Feature request » Bug report

Thank you very much, sano, patch in #3 works.
This is an obvious bug as tokens are offered to be used in the custom error message, but don't work.
I think this straight-forward fix should be committed.

g089h515r806’s picture

Status: Active » Closed (won't fix)

it is supported in set_error method.

  public function set_error($tokens = array()) {
    $error_element = $this->get_error_element();
    $error_message = t($this->get_error_message());
    $tokens += array(
      '[entity-type]' => $this->rule->entity_type, 
      '[bundle]' => $this->rule->bundle, 
      '[field-name]' => $this->instance['label'], 
      '[value]' => $this->value, 
    );
    $error_message = field_filter_xss(strtr($error_message, $tokens));