Setting #access = FALSE on a vertical tab does not prevent input processing of the contained form elements

Created on 31 May 2012, over 12 years ago
Updated 26 January 2025, about 23 hours ago

Problem/Motivation

When a form element of '#type' => 'vertical_tab' has '#access' => FALSE, none of the elements contained by that vertical tab are present in the submitted values.

The docs for #access say:

Whether the element is accessible or not; when FALSE, the element is not rendered and the user submitted value is not taken into consideration.

They don't clarify what happens to the #default_value, but after consulting chx and davereid on IRC, I was assured that the default values would still be in the submitted values:

davereid: I would assume any element output with #access = FALSE to still retain it's FAPI #default_value on submission.

Steps to Reproduce

Write a custom module called access_false.module, with the following code:

/**
 * Implements hook_form_BASE_FORM_ID_alter() for node_form.
 */
function access_false_form_node_form_alter(&$form, &$form_state, $form_id) {                                
  $form['additional_settings']['#access'] = FALSE;                                                       
}

And then try to save a node. It will be unpublished, regardless of the default publishing settings for that content type.

Proposed resolution

TBD

Remaining tasks

  • TBD

User interface changes

N/A

API changes

Any custom code relying on this bug (denying access to a vertical tab to suppress all values including defaults) will break.

πŸ› Bug report
Status

Fixed

Version

8.0 ⚰️

Component

forms system

Created by

πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia

Live updates comments and jobs are added and updated live.
  • API change

    Changes an existing API or subsystem. Not backportable to earlier major versions, unless absolutely required to fix a critical bug.

  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024