You are here

function content_default_value in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 5 content.module \content_default_value()
  2. 6.3 content.module \content_default_value()
  3. 6.2 content.module \content_default_value()

Helper function to return the correct default value for a field.

Parameters

$node: The node. @param $field The field array. @param $items The value of the field in the node. @return The default value for that field.

1 string reference to 'content_default_value'
content_field_form in includes/content.node_form.inc
Create a separate form element for each field.

File

./content.module, line 1785
Allows administrators to associate custom fields to content types.

Code

function content_default_value(&$form, &$form_state, $field, $delta) {
  $widget_types = _content_widget_types();
  $module = $widget_types[$field['widget']['type']]['module'];
  $default_value = array();
  if (!empty($field['widget']['default_value_php'])) {
    ob_start();
    $result = eval($field['widget']['default_value_php']);
    ob_end_clean();
    if (is_array($result)) {
      $default_value = $result;
    }
  }
  elseif (!empty($field['widget']['default_value'])) {
    $default_value = $field['widget']['default_value'];
  }
  return (array) $default_value;
}