Allow disabling open/closed/schedule on field widget

Created on 23 November 2022, over 1 year ago
Updated 7 April 2024, 3 months ago

Problem/Motivation

We often allow our clients to add a webform component to a page through paragraphs, but the open/closed/scheduled options are very confusing and unnecessary for them, so we often end up form_altering them out. The form display options for the field widget allow for disabling "Enable default submission data (YAML)", but they don't offer an option for disabling the open/closed/scheduled status.

Steps to reproduce

  • Add a webform reference field to an entity.
  • Add an entity of that type and observe the open/closed/scheduled status option.
  • Go to the form display options for the field widget and observe there is no option to disable the open/closed/scheduled status.

Proposed resolution

Add an option to disabled changing the status on the webform reference field widgets.

Remaining tasks

Review patch.

User interface changes

Added an option to disable changing the status on the webform reference field widgets, similar to the option to hide the default submission data (YAML).

API changes

n/a

Data model changes

n/a

✨ Feature request
Status

Closed: won't fix

Version

6.2

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium seutje Antwerp

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡¨πŸ‡ΏCzech Republic parisek

    Working great for me too. Tests are green. RTBC

  • πŸ‡¨πŸ‡ΏCzech Republic parisek
  • πŸ‡°πŸ‡ΏKazakhstan usdv

    #10 works perfectly! Many thanks.

  • Is there a way I could have the webform field disabled, but have the open/closed/scheduled status enabled? I have webform nodes, and I want editors to be able to open/close the webform without allowing them to change which webform is displayed.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 9 months ago
    535 pass
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update 9 months ago
    535 pass
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update 9 months ago
    535 pass
  • Status changed to Postponed 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    @parisek I appreciate your effort on the feature and patch. The webform module is running into a point where we need to slow down adding new features. You see how this feature request is snowballing into another reasonable feature request in #15.

    At the same time, I think a well-documented form/element alter hook that documents how to hide the webform field properties. could be a reasonable compromise.

    I am going to move to postponed to leave the discussion open.

  • Here's what I used.

    function my_module_form_alter(array &$form, FormStateInterface $form_state, string $form_id): void {
      if ($form_id === 'node_webform_edit_form' || $form_id === 'node_webform_form') {
        if (!\Drupal::currentUser()->hasPermission('edit any webform')) {
          // Deny access to change which webform is shown.
          $form['webform']['widget'][0]['target_id']['#access'] = FALSE;
          // Deny access to edit webform settings YAML, if enabled.
          if (isset($form['webform']['widget'][0]['settings']['default_data'])) {
            $form['webform']['widget'][0]['settings']['default_data']['#access'] = FALSE;
          }
        }
      }
    }
    
  • Status changed to Closed: won't fix 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY
Production build 0.69.0 2024