Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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'
Comment | File | Size | Author |
---|---|---|---|
#11 | 1055234-11-field-bundle-visibility.patch | 1.21 KB | linclark |
#5 | 1055234-v2.patch | 2.18 KB | jhodgdon |
#4 | 1055234.patch | 2.18 KB | jhodgdon |
Comments
Comment #1
manimejia CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: Dries commentedPatch no longer applies to 8.x or 7.x. Needs a re-roll.
Comment #9
Dries CreditAttribution: Dries commented#5: 1055234-v2.patch queued for re-testing.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous 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 CreditAttribution: Dries commentedCommitted to 7.x and 8.x. Thanks all!