Commit 2dbdede0 authored by yched's avatar yched

display field label in field error messages

parent 48076560
...@@ -127,7 +127,7 @@ function nodereference_field($op, &$node, $field, &$items, $teaser, $page) { ...@@ -127,7 +127,7 @@ function nodereference_field($op, &$node, $field, &$items, $teaser, $page) {
unset($item['error_field']); unset($item['error_field']);
if (!empty($item['nid'])) { if (!empty($item['nid'])) {
if (!in_array($item['nid'], array_keys($refs))) { if (!in_array($item['nid'], array_keys($refs))) {
form_set_error($error_field, t('This post can\'t be referenced.')); form_set_error($error_field, t('%name : This post can\'t be referenced.', array('%name' => t($field['widget']['label']))));
} }
} }
} }
...@@ -242,8 +242,8 @@ function nodereference_widget($op, &$node, $field, &$items) { ...@@ -242,8 +242,8 @@ function nodereference_widget($op, &$node, $field, &$items) {
} }
// Remove the widget's data representation so it isn't saved. // Remove the widget's data representation so it isn't saved.
unset($items['nids']); unset($items['nids']);
foreach($items as $delta => $item) { foreach ($items as $delta => $item) {
$items[$delta]['error_field'] = $field['field_name'].'][nids'; $items[$delta]['error_field'] = $field['field_name'] .'][nids';
} }
} }
} }
...@@ -302,14 +302,14 @@ function nodereference_widget($op, &$node, $field, &$items) { ...@@ -302,14 +302,14 @@ function nodereference_widget($op, &$node, $field, &$items) {
case 'validate': case 'validate':
foreach ($items as $delta => $item) { foreach ($items as $delta => $item) {
$error_field = $field['field_name'].']['.$delta.'][node_name'; $error_field = $field['field_name'] .']['. $delta .'][node_name';
if (!empty($item['node_name'])) { if (!empty($item['node_name'])) {
preg_match('/^(?:\s*|(.*) )?\[\s*nid\s*:\s*(\d+)\s*\]$/', $item['node_name'], $matches); preg_match('/^(?:\s*|(.*) )?\[\s*nid\s*:\s*(\d+)\s*\]$/', $item['node_name'], $matches);
if (!empty($matches)) { if (!empty($matches)) {
// explicit nid // explicit nid
list(, $title, $nid) = $matches; list(, $title, $nid) = $matches;
if (!empty($title) && ($n = node_load($nid)) && $title != $n->title) { if (!empty($title) && ($n = node_load($nid)) && $title != $n->title) {
form_set_error($error_field, t('Title mismatch. Please check your selection.')); form_set_error($error_field, t('%name : Title mismatch. Please check your selection.'), array('%name' => t($field['widget']['label'])));
} }
} }
} }
...@@ -339,7 +339,7 @@ function nodereference_widget($op, &$node, $field, &$items) { ...@@ -339,7 +339,7 @@ function nodereference_widget($op, &$node, $field, &$items) {
unset($items[$delta]['node_name']); unset($items[$delta]['node_name']);
if (!empty($nid)) { if (!empty($nid)) {
$items[$delta]['nid'] = $nid; $items[$delta]['nid'] = $nid;
$items[$delta]['error_field'] = $field['field_name'].']['.$delta.'][node_name'; $items[$delta]['error_field'] = $field['field_name'] .']['. $delta .'][node_name';
} }
elseif ($delta > 0) { elseif ($delta > 0) {
// Don't save empty fields when they're not the first value (keep '0' otherwise) // Don't save empty fields when they're not the first value (keep '0' otherwise)
......
...@@ -72,7 +72,7 @@ function userreference_field($op, &$node, $field, &$items, $teaser, $page) { ...@@ -72,7 +72,7 @@ function userreference_field($op, &$node, $field, &$items, $teaser, $page) {
$error_field = isset($item['error_field']) ? $item['error_field'] : ''; $error_field = isset($item['error_field']) ? $item['error_field'] : '';
unset($item['error_field']); unset($item['error_field']);
if (!empty($item['uid']) && !in_array($item['uid'], array_keys(_userreference_potential_references($field)))) { if (!empty($item['uid']) && !in_array($item['uid'], array_keys(_userreference_potential_references($field)))) {
form_set_error($error_field, t('Invalid user.')); form_set_error($error_field, t('%name : Invalid user.', array('%name' => t($field['widget']['label']))));
} }
} }
return; return;
...@@ -184,8 +184,8 @@ function userreference_widget($op, &$node, $field, &$items) { ...@@ -184,8 +184,8 @@ function userreference_widget($op, &$node, $field, &$items) {
} }
// Remove the widget's data representation so it isn't saved. // Remove the widget's data representation so it isn't saved.
unset($items['uids']); unset($items['uids']);
foreach($items as $delta => $item) { foreach ($items as $delta => $item) {
$items[$delta]['error_field'] = $field['field_name'].'][uids'; $items[$delta]['error_field'] = $field['field_name'] .'][uids';
} }
} }
} }
...@@ -250,7 +250,7 @@ function userreference_widget($op, &$node, $field, &$items) { ...@@ -250,7 +250,7 @@ function userreference_widget($op, &$node, $field, &$items) {
// Remove the widget's data representation so it isn't saved. // Remove the widget's data representation so it isn't saved.
unset($items[$delta]['user_name']); unset($items[$delta]['user_name']);
$items[$delta]['uid'] = $uid; $items[$delta]['uid'] = $uid;
$items[$delta]['error_field'] = $field['field_name'].']['.$delta.'][user_name'; $items[$delta]['error_field'] = $field['field_name'] .']['. $delta .'][user_name';
// Don't save empty fields except the first value // Don't save empty fields except the first value
if (empty($uid) && $delta > 0) { if (empty($uid) && $delta > 0) {
unset($items[$delta]); unset($items[$delta]);
......
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