Commit cfc3e7d3 authored by Xano's avatar Xano Committed by John Fiala
Browse files

Issue #2351223 by Xano: Improve field validation error message.

parent 4a23179b
......@@ -406,7 +406,10 @@ function _link_validate(&$item, $delta, $field, $entity, $instance, $langcode, &
if (link_validate_url(trim($item['url'])) == FALSE) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'link_required',
'message' => t('The value provided for %field is not a valid URL.', array('%field' => $instance['label'])),
'message' => t('The value %value provided for %field is not a valid URL.', array(
'%value' => trim($item['url']),
'%field' => $instance['label'],
)),
'error_element' => array('url' => TRUE, 'title' => FALSE),
);
}
......
......@@ -143,7 +143,7 @@ class LinkUITest extends DrupalWebTestcase {
);
$this->drupalPost(NULL, $edit, t('Save'));
if ($input['type'] == self::LINK_INPUT_TYPE_BAD_URL) {
$this->assertRaw(t('The value provided for %field is not a valid URL.', array('%field' => $name)), 'Not a valid URL: ' . $input['href']);
$this->assertRaw(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => trim($input['href']))), 'Not a valid URL: ' . $input['href']);
continue;
}
else {
......
......@@ -100,7 +100,7 @@ class LinkValidateTest extends LinkValidateTestCase {
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
$this->assertText(t('The value @value provided for @field is not a valid URL.', array('@value' => 'edik:naw', '@field' => $name)));
}
/**
......@@ -145,7 +145,7 @@ class LinkValidateTest extends LinkValidateTestCase {
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
$this->assertText(t('The value @value provided for @field is not a valid URL.', array('@field' => $name, '@value' => 'edik:naw')));
}
......@@ -195,7 +195,7 @@ class LinkValidateTest extends LinkValidateTestCase {
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertNoText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => 'edik:naw')));
}
/**
......@@ -237,7 +237,7 @@ class LinkValidateTest extends LinkValidateTestCase {
$this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
//$this->pass($this->content);
$this->assertNoText(t('The value provided for %field is not a valid URL.', array('%field' => $name)));
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => trim($url))));
// Make sure we get a new version!
$node = node_load($this->nodes[0]->nid, NULL, TRUE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment