To set or get the 'visibility' of an 'extra' field using field_bundle_settings(),
the example in code says this:
'extra_field_1' => array(
// One sub-array per view mode for the entity type, including
// the 'default' mode:
'default' => array(
'weight' => The weight of the pseudo-field,
'visibility' => Whether the pseudo-field is visible or hidden,
),
'full' => ...
),
But the code in field_ui_display_overview_form_submit() says this:
// Save data for 'extra' fields.
foreach ($form['#extra'] as $name) {
$bundle_settings['extra_fields']['display'][$name][$view_mode] = array(
'weight' => $form_values['fields'][$name]['weight'],
'visible' => $form_values['fields'][$name]['type'] == 'visible',
);
}
The difference
is that 'visibility' is controlled by:
$view_mode['visible'] = TRUE; // or FALSE
and NOT by
$view_mode['visibility'] = 'visible';// looks like values are 'visible' or 'hidden'
Comments
Comment #1
manimejia commentedComment #2
jhodgdonThat assessment looks correct to me, but we should also check the code that uses the bundle settings and verify there.
Comment #3
jhodgdonI grepped through the code, and am seeing 'visibility' being used in:
- hook_field_extra_fields_display_alter() -- sample function body
- field_info_extra_fields() docblock example (similar to the one in this issue)
Ah. _field_extra_fields_pre_render(), which actually uses the visibility information referenced here, is definitely looking for a ['visible'] component as a boolean. And I found this usage in other spots too... So I can confirm the analysis in this issue report. The 2 above spots also need to be fixed along with the spot reported in this issue.
Comment #4
jhodgdonHere's a patch.
Comment #5
jhodgdonIt might help if I could spell visible. Try this patch instead.
Comment #6
kim-day commentedThe patch looks good to me. It fixes the 3 instances correctly.
Comment #7
jhodgdonRTBC as per #6. Should be applied to 8.x and 7.x.
Comment #8
dries commentedPatch no longer applies to 8.x or 7.x. Needs a re-roll.
Comment #9
dries commented#5: 1055234-v2.patch queued for re-testing.
Comment #11
Anonymous (not verified) commentedI rerolled the patch. It looks like the last instance, in field.api.php, must have been caught in another patch. Comment #3 has the summary.
Comment #12
jhodgdonThanks linclark! Assuming the test bot agrees and the patch applies, this should be back to RTBC. Confirmed that the third hunk from the previous patch is already at
http://api.drupal.org/api/drupal/modules--field--field.api.php/function/...
Comment #13
dries commentedCommitted to 7.x and 8.x. Thanks all!