Я пытаюсь выяснить, что не так с этим битом php-кода Drupal 6, который я пытаюсь заставить работать в Drupal 7:
function node_widget_get_fields(&$form) {
$fields = array();
if (isset($form['#type'])) {
$content_type = content_types($form['#type']['#value']);
foreach ($content_type['fields'] as $field_name => $field) {
if ($field['type'] == 'nodereference' && $field['widget']['type'] ==
'node_widget_node_form') {
$fields[$field_name] = $field;
}
}
}
return $fields;
Вот как далеко у меня:
function node_widget_get_fields(&$form) {
$fields = array();
if (isset($form['#type'])) {
$content_type = field_info_instances($form['#type']['#value']);
foreach ($content_type['fields'] as $field_name => $field) {
if ($field['type'] == 'nodereference' && $field['widget']['type'] ==
'node_widget_node_form') {
$fields[$field_name] = $field;
}
}
}
return $fields;
возвращено ошибок:
Notice: Undefined index: f in field_info_instances() (line 682 of /modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in node_widget_get_fields() (line 164 of all/modules/node_widget/includes/node_widget.form.inc).
и
Notice: Undefined index: how_to in field_info_instances() (line 682 of /var/www/bitbybit/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in node_widget_get_fields() (line 164 of /var/www/bitbybit/sites/all/modules/node_widget/includes/node_widget.form.inc).
Notice: Undefined index: type in node_widget_get_fields() (line 163 of /var/www/bitbybit/sites/all/modules/node_widget/includes/node_widget.form.inc).
Notice: Undefined index: fields in node_widget_get_fields() (line 164 of /var/www/bitbybit/sites/all/modules/node_widget/includes/node_widget.form.inc).