function tablefield_field_presave in TableField 7
Same name and namespace in other branches
- 7.3 tablefield.module \tablefield_field_presave()
- 7.2 tablefield.module \tablefield_field_presave()
Implements hook_field_presave().
File
- ./
tablefield.module, line 77 - This module provides a set of fields that can be used to store tabular data with a node. The implementation uses a custom CCK widget.
Code
function tablefield_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
foreach ($items as $delta => $table) {
if (empty($table['value'])) {
$tablefield = array();
foreach ($table['tablefield'] as $key => $value) {
$tablefield[$key] = $value;
}
$items[$delta]['value'] = serialize($tablefield);
}
elseif (empty($table['tablefield'])) {
// Batch processing only provides the 'value'
$items[$delta]['tablefield'] = unserialize($items[$delta]['value']);
}
}
}