Use conditional logic to show/hide webform_booking fields bring to PluginNotFoundException

Created on 28 February 2024, 10 months ago
Updated 21 March 2024, 9 months ago

Problem/Motivation

there is a problem when using two fields and showing them with conditional logic according to a select field's value,

on webform submit, an error is thrown:

An HTTP error occurred in AJAX.
HTTP response code: 500
The following is debug information.
Path: /analytica-9-12-april-2024?ajax_form=1
StatusText: 500 Service unavailable ( with message)
ResponseText: An unexpected error occurred. Please try again later, thanks.

Drupal\\Component\\Plugin\\Exception\\PluginNotFoundException: The "webform_booking" plugin does not exist. Valid plugin IDs for Drupal\\Core\\Render\\ElementInfoManager are: captcha, contextual_links_placeholder, contextual_links, field_group_html_element, field_group_accordion_item, horizontal_tabs, field_group_accordion, field_ui_table, managed_file, file_mdm_caching, text_format, processed_text, image_effects_color, image_effects_px_perc, image_crop, language_configuration, linkit, status_report_page, taxonomy_manager_tree, token_tree_table, toolbar_item, toolbar, video_embed_iframe, webform_telephone, webform_submission_navigation, webform_checkboxes_other, webform_same, webform_help, webform_custom_composite, webform, webform_terms_of_service, webform_video_file, webform_submission_information, webform_name, webform_entity_radios, webform_mapping, webform_autocomplete, webform_table, webform_html_editor, webform_element_options, webform_computed_token, webform_flexbox, webform_section, webform_excluded_elements, webform_roles, webform_email_confirm, webform_address, webform_scale, webform_radios_other, webform_entity_checkboxes, webform_rating, webform_markup, webform_link, webform_horizontal_rule, webform_element_composite, webform_computed_twig, webform_submission_views_replace, webform_element_attributes, webform_variant, webform_submission_views, webform_document_file, webform_options, webform_likert, webform_more, webform_codemirror, webform_entity_select, webform_email_multiple, webform_audio_file, webform_checkbox_value, webform_select_other, webform_time, webform_permissions, webform_table_sort, webform_image_file, webform_tableselect_sort, webform_signature, webform_table_row, webform_excluded_columns, webform_users, webform_height, webform_term_select, webform_wizard_page, webform_actions, webform_contact, webform_image_resolution, webform_message, webform_element_states, webform_location_places, webform_term_checkboxes, webform_element_multiple, webform_multiple, webform_attachment_token, webform_attachment_url, webform_attachment_twig, view, paragraphs_actions, paragraph_operations, entity_autocomplete, break_lock_link, datelist, datetime, ajax, path, item, number, operations, table, form, label, html_tag, token, radios, email, button, checkboxes, radio, page, status_messages, hidden, details, checkbox, container, image_button, html, system_compact_link, weight, inline_template, language_select, status_report, fieldset, file, link, textarea, tableselect, machine_name, dropbutton, actions, submit, password, more_link, color, password_confirm, date, select, search, value, tel, fieldgroup, pager, vertical_tabs, range, url, page_title, textfield in Drupal\\Core\\Plugin\\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php). Drupal\\Core\\Plugin\\DefaultPluginManager->getDefinition("webform_booking") (Line: 428)\nDrupal\\webform\\Plugin\\WebformElementBase->getFormElementClassDefinition() (Line: 370)
...

Steps to reproduce

Tested with vanilla drupal 10.2.3 and webform 6.2.2 on simplytest.me with a simple form made by 3 fields

  • A) a select with two value 1 and 2
  • B) a webform_booking active if A) is equal to 1
  • C) a webform_booking active if A) is equal to 2

here the webform yml:

select_test:
  '#type': select
  '#title': 'Select test'
  '#options':
    1: '1'
    2: '2'
test_booking_1:
  '#type': booking
  '#title': 'test booking 1'
  '#required': true
  '#states':
    visible:
      ':input[name="select_test"]':
        value: '1'
  '#start_date': '2024-04-09'
  '#end_date': '2024-04-13'
  '#excluded_weekdays':
    Mon: 0
    Tue: 0
    Wed: 0
    Thu: 0
    Fri: 0
    Sat: 0
    Sun: 0
  '#time_interval': |-
    08:00|12:00
    13:00|18:00
  '#slot_duration': '60'
test_booking_2:
  '#type': booking
  '#title': 'test booking 2'
  '#required': true
  '#states':
    visible:
      ':input[name="select_test"]':
        value: '2'
  '#start_date': '2024-04-09'
  '#end_date': '2024-04-13'
  '#excluded_weekdays':
    Mon: 0
    Tue: 0
    Wed: 0
    Thu: 0
    Fri: 0
    Sat: 0
    Sun: 0
  '#time_interval': |-
    08:00|12:00
    13:00|18:00
  '#slot_duration': '60'

Proposed resolution

adding the Element definition solve the issue (src/Element/WebformBooking.php)

see webform_example_element submodule

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇹Italy d.sibaud Perugia

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

Comments & Activities

Production build 0.71.5 2024