field_get_default_value

Versions
7
field_get_default_value($obj_type, $object, $field, $instance, $langcode = NULL)

Helper function to get the default value for a field on an object.

Parameters

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

$object The object for the operation.

$field The field structure.

$instance The instance structure.

$langcode The field language to fill-in with the default value.

Related topics

▾ 2 functions call field_get_default_value()

field_default_form in modules/field/field.form.inc
Create a separate form element for each field.
field_default_insert in modules/field/field.default.inc
Default field 'insert' operation.

Code

modules/field/field.module, line 290

<?php
function field_get_default_value($obj_type, $object, $field, $instance, $langcode = NULL) {
  $items = array();
  if (!empty($instance['default_value_function'])) {
    $function = $instance['default_value_function'];
    if (function_exists($function)) {
      $items = $function($obj_type, $object, $field, $instance, $langcode);
    }
  }
  elseif (!empty($instance['default_value'])) {
    $items = $instance['default_value'];
  }
  return $items;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.