function mymodule_views_data() {
...
  $data['mymodule']['myfield'] => array(
    'title' => t('My module field'),
    'help' => t('Help text'),
    'field' => array(),
  );
..
  return $data;
}

The field "My module field" will not show up because of too restrictive validation checking. As it is sufficient to define title, group or help outside the field array the $info[$key] variable should be allowed to be empty.

--- includes/admin.inc	7 Apr 2009 20:48:28 -0000	1.154
+++ includes/admin.inc	23 Aug 2009 13:55:58 -0000
@@ -2893,7 +2893,7 @@ function views_fetch_fields($base, $type
           continue;
         }
         foreach (array('field', 'sort', 'filter', 'argument', 'relationship') as $key) {
-          if (!empty($info[$key])) {
+          if (is_array($info[$key])) {
             if (!empty($info[$key]['skip base'])) {
               foreach ((array) $info[$key]['skip base'] as $base_name) {
                 $skip_bases[$field][$key][$base_name] = TRUE;

Greetings,
sevi

CommentFileSizeAuthor
views-field-definition.patch794 bytessevi

Comments

dawehner’s picture

Status: Active » Needs review

Update status

Patch looks fine for me

merlinofchaos’s picture

Status: Needs review » Closed (won't fix)

But 'field' => array() is not truly valid. It's also more obscure in terms of reading to see what's going on. I don't think I agree with this.