_field_invoke

  1. drupal
    1. drupal7
Versionen
drupal7 _field_invoke($op, $obj_type, &$object, &$a = NULL, &$b = NULL, $default = FALSE)

Invoke a field hook.

Übergabeparameter

$op Possible operations include:

  • form
  • validate
  • presave
  • insert
  • update
  • delete
  • delete revision
  • sanitize
  • view
  • preprocess
  • prepare translation

$obj_type The type of $object; e.g. 'node' or 'user'.

$object The fully formed $obj_type object.

$a

  • The $form in the 'form' operation.
  • The value of $teaser in the 'view' operation.
  • Otherwise NULL.

$b

  • The $form_state in the 'submit' operation.
  • Otherwise NULL.

$default

  • TRUE: use the default field implementation of the field hook.
  • FALSE: use the field module's implementation of the field hook.

Verwandte Themen

▾ 9 functions call _field_invoke()

_field_attach_delete in modules/field/field.attach.inc
Delete field data for an existing object. This deletes all revisions of field data for the object.
_field_attach_delete_revision in modules/field/field.attach.inc
Delete field data for a single revision of an existing object. The passed object must have a revision id attribute.
_field_attach_insert in modules/field/field.attach.inc
Save field data for a new object.
_field_attach_prepare_translation in modules/field/field.attach.inc
Implementation of hook_node_prepare_translation.
_field_attach_presave in modules/field/field.attach.inc
Perform necessary operations just before fields data get saved.
_field_attach_update in modules/field/field.attach.inc
Save field data for an existing object.
_field_attach_validate in modules/field/field.attach.inc
Perform field validation against the field data in an object.
_field_attach_view in modules/field/field.attach.inc
Generate and return a structured content array tree suitable for drupal_render() for all of the fields on an object. The format of each field's rendered content depends on the display formatter and its settings.
_field_invoke_default in modules/field/field.attach.inc
Invoke field.module's version of a field hook.

Code

modules/field/field.attach.inc, line 158

<?php
function _field_invoke($op, $obj_type, &$object, &$a = NULL, &$b = NULL, $default = FALSE) {
  list(, , $bundle) = field_attach_extract_ids($obj_type, $object);
  $instances = field_info_instances($bundle);

  $return = array();
  foreach ($instances as $instance) {
    $field_name = $instance['field_name'];
    $field = field_info_field($field_name);
    $items = isset($object->$field_name) ? $object->$field_name : array();

    $function = $default ? 'field_default_' . $op : $field['module'] . '_field_' . $op;
    if (drupal_function_exists($function)) {
      $result = $function($obj_type, $object, $field, $instance, $items, $a, $b);
      if (is_array($result)) {
        $return = array_merge($return, $result);
      }
      elseif (isset($result)) {
        $return[] = $result;
      }
    }
    // Populate field values back in the object, but avoid replacing missing
    // fields with an empty array (those are not equivalent on update).
    if ($items !== array() || property_exists($object, $field_name)) {
      $object->$field_name = $items;
    }
  }

  return $return;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen