Commit c21233f8 authored by yched's avatar yched

#123667 - incomplete example code for hook_field('view') - thanks RobRoy

parent d63c0229
......@@ -198,6 +198,7 @@ function hook_field_settings($op, $field) {
function hook_field($op, &$node, $field, &$node_field, $teaser, $page) {
switch ($op) {
case 'view':
$context = $teaser ? 'teaser' : 'full';
$formatter = isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
$items = array();
foreach ($node_field as $delta => $item) {
......@@ -210,7 +211,7 @@ function hook_field($op, &$node, $field, &$node_field, $teaser, $page) {
if (is_array($items)) {
foreach ($items as $delta => $item) {
$error_field = $field['field_name'].']['.$delta.'][value';
$error_field = $field['field_name']. ']['. $delta.'][value';
if ($item['value'] != '') {
if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) {
form_set_error($error_field, t('Illegal value for %name.', array('%name' => t($field['widget']['label']))));
......
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