function content_set_empty in Content Construction Kit (CCK) 6.2
Same name and namespace in other branches
- 6.3 content.module \content_set_empty()
- 6 content.module \content_set_empty()
Helper function to filter out empty values.
On order to keep marker rows in the database, the function ensures that the right number of 'all columns NULL' values is kept.
Parameters
array $field:
array $items:
Return value
array returns filtered and adjusted item array
3 calls to content_set_empty()
- content_field in ./
content.module - Implementation of hook_field(). Handles common field housekeeping.
- content_field_replace in includes/
content.admin.inc - Content Field Replace
- content_multiple_value_form in includes/
content.node_form.inc - Special handling to create form elements for multiple values.
File
- ./
content.module, line 903 - Allows administrators to associate custom fields to content types.
Code
function content_set_empty($field, $items) {
// Filter out empty values.
$filtered = array();
$function = $field['module'] . '_content_is_empty';
foreach ((array) $items as $delta => $item) {
if (!$function($item, $field)) {
$filtered[] = $item;
}
}
// Make sure we store the right number of 'empty' values.
$empty = array();
foreach (array_keys($field['columns']) as $column) {
$empty[$column] = NULL;
}
$pad = $field['multiple'] > 1 ? $field['multiple'] : 1;
$filtered = array_pad($filtered, $pad, $empty);
return $filtered;
}