warning: Invalid argument supplied for foreach() in /var/alternc/html/s/spc/lib/php/cms/drupal/6.x/sites/all/modules/date_picker_formatter/date_picker_formatter.module on line 87.
  • This warning message shows on node view page.
  • The CCK datetime field on which Formatter Selector is applied is completly hidden due to a bug.
  • The CCK datetime field is configured with allowed formatters : defauld and date_picker_formatter
  • admin/content/node-type/.../display is configured to default
83 function date_picker_formatter_get_votes($node, $field) {
84  $criteria = _date_picker_formatter_get_vote_criteria($node);
85  $date_picker_formatter = array();
86  
87  foreach ($node->{$field['field_name']} as $item) { // warning: Invalid argument supplied for foreach()
88    $criteria['tag'] = _date_picker_formatter_vote_tag($item);
89    $votes = votingapi_select_votes($criteria);
90    foreach ($votes as $vote) {
91      $date_picker_formatter[$vote['uid']][$vote['tag']] = $vote;
92    }
93  }
94  return $date_picker_formatter;
95 }

Comments

nardberjean’s picture

nardberjean’s picture

The problem appears when date_picker_formatter is selected in node edit form.

zeropaper’s picture

Ok, thanks for pointing this out, a simple "is_array()" will probably do the trick..

nardberjean’s picture

Not sure to understand your suggestion.
I added on line 86

drupal_set_message(var_export($node->{$field['field_name']}, true), 'test');

and I got the result

NULL

I also got NULL for $field['field_name'] and for $field and for $node on the site default main page linking to nodes with the formatted fields and on the node page itself.

thepanz’s picture

Version: 6.x-1.0-beta1 » 6.x-2.x-dev
Status: Active » Postponed (maintainer needs more info)

Please refer to 2.x branch for a clean CCK Date formatter. This should handle correctly all field settings/visibility.