function tablefield_field_is_empty in TableField 7.2
Same name and namespace in other branches
- 7.3 tablefield.module \tablefield_field_is_empty()
- 7 tablefield.module \tablefield_field_is_empty()
Implements hook_field_is_empty().
1 call to tablefield_field_is_empty()
- tablefield_field_validate in ./
tablefield.module - Implements hook_field_validate().
File
- ./
tablefield.module, line 359 - Provides a set of fields that can be used to store tabular data with a node.
Code
function tablefield_field_is_empty($item, $field) {
// @todo, is this the best way to mark the default value form?
// if we don't, it won't save the number of rows/cols
// Allow the system settings form to have an emtpy table
$arg0 = arg(0);
if ($arg0 == 'admin') {
return FALSE;
}
// Check for already serialized data. This is the case for other language
// versions of this field.
if (!empty($item['tabledata'])) {
return FALSE;
}
$count_rows = $item['tablefield']['rebuild']['count_rows'];
// Remove the preference fields to see if the table cells are all empty.
unset($item['tablefield']['caption']);
unset($item['tablefield']['rebuild']);
unset($item['tablefield']['import']);
unset($item['tablefield']['paste']);
if (!empty($item['tablefield']['tabledata'])) {
for ($i = 0; $i < $count_rows; $i++) {
foreach ($item['tablefield']['tabledata']["row_{$i}"] as $key => $cell) {
// Keys denoting weight data and anything still iterateable should be
// ignored while checking for empty cell data.
if (strpos($key, 'weight') === FALSE && !is_array($cell) && !empty($cell)) {
return FALSE;
}
}
}
}
return TRUE;
}