function content_default_value in Content Construction Kit (CCK) 5
Same name and namespace in other branches
- 6.3 content.module \content_default_value()
- 6 content.module \content_default_value()
- 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 call to content_default_value()
- _content_widget_invoke in ./
content.module - Invoke a widget hook.
File
- ./
content.module, line 1160 - Allows administrators to associate custom fields to content types.
Code
function content_default_value($node, $field, $items) {
$widget_types = _content_widget_types();
$module = $widget_types[$field['widget']['type']]['module'];
$default_value = array();
if (content_handle('widget', 'default value', $field) == CONTENT_CALLBACK_CUSTOM) {
$function = $module . '_widget';
$default_value = $function('default value', $node, $field, $items);
}
elseif (!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;
}