Element without explicit #access => TRUE is removed by \Drupal\webform\Plugin\WebformElementBase::setConfigurationFormDefaultValueRecursive()

Created on 29 April 2024, 8 months ago

Problem/Motivation

I have tried to add the following warning to a custom Webform element in \Drupal\foo\Plugin\WebformElement\FooSelect::form() like the code example below and I was surprised when I saw that it has not been rendered. After some debugging it turned out that the logic at the end of \Drupal\webform\Plugin\WebformElementBase::setConfigurationFormDefaultValueRecursive() removes elements without explicit '#access' => TRUE,.


    $form['warning'] = [
      '#theme' => 'status_messages',
      '#message_list' => [
        'warning' => [
          $this->t('Fooo'),
        ],
      ],
//      '#access' => TRUE,
    ];

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

6.2

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary mxr576 Hungary

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mxr576
  • πŸ‡­πŸ‡ΊHungary mxr576 Hungary

    For the record, the same code works as expected without an explicit '#access' => TRUE, in a Webform handler's form builder, like \Drupal\foo\Plugin\WebformHandler\Foo::buildConfigurationForm().

  • πŸ‡­πŸ‡ΊHungary mxr576 Hungary
  • Status changed to Closed: won't fix 29 days ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    Yes, in a Webform element, a property needs to be included via ::defineDefaultProperties to have #access automatically set to TRUE. Otherwise, you must explicitly set an element on the element edit form #access to TRUE.

    We can't change this behavior.

  • πŸ‡­πŸ‡ΊHungary mxr576 Hungary

    Ack, thanks for the clarification.

Production build 0.71.5 2024