- Patch #1146088 by lyricnz: label always visible for table formatter.
parent
7be846e75d
commit
46f8c7433e
|
@ -350,11 +350,13 @@ function field_test_field_formatter_view($entity_type, $entity, $field, $instanc
|
|||
break;
|
||||
|
||||
case 'field_test_multiple':
|
||||
$array = array();
|
||||
foreach ($items as $delta => $item) {
|
||||
$array[] = $delta . ':' . $item['value'];
|
||||
if (!empty($items)) {
|
||||
$array = array();
|
||||
foreach ($items as $delta => $item) {
|
||||
$array[] = $delta . ':' . $item['value'];
|
||||
}
|
||||
$element[0] = array('#markup' => $settings['test_formatter_setting_multiple'] . '|' . implode('|', $array));
|
||||
}
|
||||
$element[0] = array('#markup' => $settings['test_formatter_setting_multiple'] . '|' . implode('|', $array));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -993,11 +993,13 @@ function file_field_formatter_view($entity_type, $entity, $field, $instance, $la
|
|||
break;
|
||||
|
||||
case 'file_table':
|
||||
// Display all values in a single element..
|
||||
$element[0] = array(
|
||||
'#theme' => 'file_formatter_table',
|
||||
'#items' => $items,
|
||||
);
|
||||
if (!empty($items)) {
|
||||
// Display all values in a single element..
|
||||
$element[0] = array(
|
||||
'#theme' => 'file_formatter_table',
|
||||
'#items' => $items,
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -760,6 +760,19 @@ class FileFieldDisplayTestCase extends FileFieldTestCase {
|
|||
$field = field_info_field($field_name);
|
||||
$instance = field_info_instance('node', $field_name, $type_name);
|
||||
|
||||
// Create a new node *without* the file field set, and check that the field
|
||||
// is not shown for each node display.
|
||||
$node = $this->drupalCreateNode(array('type' => $type_name));
|
||||
$file_formatters = array('file_default', 'file_table', 'file_url_plain', 'hidden');
|
||||
foreach ($file_formatters as $formatter) {
|
||||
$edit = array(
|
||||
"fields[$field_name][type]" => $formatter,
|
||||
);
|
||||
$this->drupalPost("admin/structure/types/manage/$type_name/display", $edit, t('Save'));
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertNoText($field_name, t('Field label is hidden when no file attached for formatter %formatter', array('%formatter' => $formatter)));
|
||||
}
|
||||
|
||||
$test_file = $this->getTestFile('text');
|
||||
|
||||
// Create a new node with the uploaded file.
|
||||
|
|
Loading…
Reference in New Issue