From c4e99382a37cee984c84e94bf03337abaeb4c172 Mon Sep 17 00:00:00 2001 From: richardgaunt <57734756+richardgaunt@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:54:26 +1100 Subject: [PATCH] Issue #3486893, #3478484, #3483064, #3415662, by joshua1234511, richardgaunt, fionamorrison23, febdao, gargsuchi, sonam.chaturvedi, mwjansen, alex.skrypnyk: Add opt-in for controlling what form elements are rendered via civictheme system. (#1306) --- .../form_elements.core_form_elements.feature | 383 ++++++++++++++++++ ...orm_elements.webform_form_elements.feature | 265 ++++++++++++ .../civictheme_dev/civictheme_dev.module | 4 - .../civictheme_dev/civictheme_dev.routing.yml | 14 + ...webform.civictheme_test_webform_fields.yml | 383 ++++++++++++++++++ .../src/Form/CoreFormElementsForm.php | 311 ++++++++++++++ .../contrib/civictheme/includes/form.inc | 57 ++- .../civictheme/includes/form_element.inc | 127 +++++- .../contrib/civictheme/includes/utilities.inc | 2 +- .../civictheme/src/CivicthemeConstants.php | 5 + ...--form-element--civictheme-field.html.twig | 2 + .../form-element--civictheme-field.html.twig | 2 + 12 files changed, 1511 insertions(+), 44 deletions(-) create mode 100644 tests/behat/features/form_elements.core_form_elements.feature create mode 100644 tests/behat/features/form_elements.webform_form_elements.feature create mode 100644 web/modules/custom/civictheme_dev/civictheme_dev.routing.yml create mode 100644 web/modules/custom/civictheme_dev/config/install/webform.webform.civictheme_test_webform_fields.yml create mode 100644 web/modules/custom/civictheme_dev/src/Form/CoreFormElementsForm.php diff --git a/tests/behat/features/form_elements.core_form_elements.feature b/tests/behat/features/form_elements.core_form_elements.feature new file mode 100644 index 000000000..5a6acf95a --- /dev/null +++ b/tests/behat/features/form_elements.core_form_elements.feature @@ -0,0 +1,383 @@ +@p1 @civictheme @civictheme_form_updates @civictheme_core_form +Feature: Test a sample of the core form elements + + @api + Scenario: Fields appear as expected in civictheme + Given I am an anonymous user + When I visit "/civictheme-core-form-elements" + + Then I should see "CivicTheme Core Form Elements Form" in the ".ct-banner__title" element + + # Button (button) + And should see an "[name='op']" element + And should not see an "[name='op'].required" element + And should not see an "[name='op'][disabled]" element + And should see an "[value='Button (button)']" element + And should see an "[data-component-name='button']" element + And should see an "[type='submit']" element + And I should see an ".ct-button.ct-theme-light.ct-button--primary.ct-button--submit.ct-button--regular" element + And I should see an ".button.js-form-submit.form-submit" element + + # Checkbox (checkbox) + And I should see an "[name='checkbox']" element + And I should see an "[id='edit-checkbox']" element + And I should see an ".ct-checkbox.ct-theme-light.ct-field__control.form-checkbox" element + + # Checkboxes (checkboxes) + And I should see an "[name='checkboxes[option1]']" element + And I should see an "[id='edit-checkboxes-option1']" element + And I should see an ".ct-checkbox.ct-theme-light.ct-field__control.form-checkbox" element + And I should see an "[name='checkboxes[option2]']" element + And I should see an "[id='edit-checkboxes-option2']" element + And I should see an ".ct-checkbox.ct-theme-light.ct-field__control.form-checkbox" element + And I should see an "[name='checkboxes[option3]']" element + And I should see an "[id='edit-checkboxes-option3']" element + And I should see an ".ct-checkbox.ct-theme-light.ct-field__control.form-checkbox" element + + # Date (date) + And I should see an "[name='date']" element + And I should see an "[id='edit-date']" element + And I should see an ".form-date.form-element.form-element--type-date.form-element--api-date.form-control" element + + # Datelist (datelist) + And I should see an "[name='datelist[year]']" element + And I should see an "[id='edit-datelist-year']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select" element + And I should see an "[name='datelist[month]']" element + And I should see an "[id='edit-datelist-month']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select" element + And I should see an "[name='datelist[day]']" element + And I should see an "[id='edit-datelist-day']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select" element + And I should see an "[name='datelist[hour]']" element + And I should see an "[id='edit-datelist-hour']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select" element + And I should see an "[name='datelist[minute]']" element + And I should see an "[id='edit-datelist-minute']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select" element + + # Datetime (datetime) + And I should see an "[name='datetime[date]']" element + And I should see an "[id='edit-datetime-date']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-date" element + And I should see an "[name='datetime[time]']" element + And I should see an "[id='edit-datetime-time']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-time" element + + # Email (email) + And I should see an "[name='email']" element + And I should see an "[id='edit-email']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-email" element + And I should see an ".form-email.form-element.form-element--type-email.form-element--api-email.form-control" element + + # Entity Autocomplete (entity_autocomplete) + And I should see an "[name='entity_autocomplete']" element + And I should see an "[id='edit-entity-autocomplete']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-autocomplete" element + + # File (file) + And I should see an "[name='files[file]']" element + And I should see an "[id='edit-file']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-file" element + + # Image Button (image_button) + And I should see an "[name='op'][type='image']" element + And I should see an "[id='edit-1--2']" element + And I should see an "[src='/themes/contrib/civictheme/assets/icons/download.svg']" element + + # Linkit (linkit) + And I should see an "[name='linkit']" element + And I should see an "[id='edit-linkit']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-text" element + + # Machine Name (machine_name) + And I should see an "[name='machine_name']" element + And I should see an "[id='edit-machine-name']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-text" element + + # Number (number) + And I should see an "[name='number']" element + And I should see an "[id='edit-number']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-number" element + And I should see an ".form-number.form-element.form-element--type-number.form-element--api-number.form-control" element + + # Password (password) + And I should see an "[name='password']" element + And I should see an "[id='edit-password']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-text" element + + # Password Confirm (password_confirm) + And I should see an "[name='password_confirm[pass1]']" element + And I should see an "[id='edit-password-confirm-pass1']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-text" element + And I should see an "[name='password_confirm[pass2]']" element + And I should see an "[id='edit-password-confirm-pass2']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-text" element + And I should see an ".form-text.form-element.form-element--type-password.form-element--api-password.form-control" element + And I should see an ".password-confirm.js-password-confirm" element + + # Path (path) + And I should see an "[name='path']" element + And I should see an "[id='edit-path']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-text" element + + # Radio (radio) + And I should see an "[name='radio']" element + And I should see an "[id='edit-radio']" element + And I should see an ".ct-radio.ct-theme-light.ct-field__control.form-radio" element + + # Radios (radios) + And I should see an "[name='radios']" element + And I should see an "[id='edit-radios-option1']" element + And I should see an ".ct-radio.ct-theme-light.ct-field__control.form-radio" element + And I should see an "[name='radios']" element + And I should see an "[id='edit-radios-option2']" element + And I should see an ".ct-radio.ct-theme-light.ct-field__control.form-radio" element + And I should see an "[name='radios']" element + And I should see an "[id='edit-radios-option3']" element + And I should see an ".ct-radio.ct-theme-light.ct-field__control.form-radio" element + + # Range (range) + And I should see an "[name='range']" element + And I should see an "[id='edit-range']" element + And I should not see an ".ct-input.ct-theme-light.ct-field__control.form-range" element + + # Search (search) + And I should see an "[name='search']" element + And I should see an "[id='edit-search']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-search" element + + # Select (select) + And I should not see an "[name='select']" element + And I should not see an "[id='edit-select']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select" element + + # Submit (submit) + And I should see an "[name='op'][type='submit']" element + And I should see an "[id='edit-1--3']" element + And I should see an ".ct-button.ct-theme-light.ct-button--primary.ct-button--submit" element + + # Table (table) + And I should see an "[id='edit-table']" element + And I should see an ".ct-table.ct-theme-light.ct-table--caption-before" element + + # Tel (tel) + And I should see an "[name='tel']" element + And I should see an "[id='edit-tel']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-tel" element + And I should see an ".form-tel.form-element.form-element--type-tel.form-element--api-tel.form-control" element + + # Textarea (textarea) + And I should see an "[name='textarea']" element + And I should see an "[id='edit-textarea']" element + And I should see an ".ct-textarea.ct-theme-light.ct-field__control.form-element" element + + # Textfield (textfield) + And I should see an "[name='textfield']" element + And I should see an "[id='edit-textfield']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text" element + + # Url (url) + And I should see an "[name='url']" element + And I should see an "[id='edit-url']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-url" element + And I should see an ".form-url.form-element.form-element--type-url.form-element--api-url.form-control" element + + # Weight (weight) + And I should see an "[name='weight']" element + And I should see an "[id='edit-weight']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select" element + + # Markup within a form + And I should see "Markup within a form" in the "h2" element + And I should see "Test content 1" in the "p" element + And I should see an ".ct-basic-content.ct-theme-light ul li" element + And I should see the text "List Item 1" + And I should see the text "List Item 2" + And I should see the text "List Item 3" + And I should see an ".ct-link" element + And I should see the link "Examples" with "https://www.drupal.org/docs/8/api/form-api/examples" + + @api + Scenario: Fields appear as expected in admin theme + Given I am logged in as a user with the "Site Administrator" role + When I visit "/admin/structure/civictheme-core-form-elements" + + Then I should see "Core Form Elements Form (Admin Theme)" in the ".page-title" element + + # Button (button) + And should see an "[name='op']" element + And should not see an "[name='op'].required" element + And should not see an "[name='op'][disabled]" element + And should see an "[value='Button (button)']" element + And should not see an "[data-component-name='button']" element + And should see an "[type='submit']" element + And I should not see an ".ct-button.ct-theme-light.ct-button--primary.ct-button--submit.ct-button--regular" element + And I should see an ".button.js-form-submit.form-submit" element + + # Checkbox (checkbox) + And I should see an "[name='checkbox']" element + And I should see an "[id='edit-checkbox']" element + And I should see an ".form-checkbox.form-boolean.form-boolean--type-checkbox" element + + # Checkboxes (checkboxes) + And I should see an "[name='checkboxes[option1]']" element + And I should see an "[id='edit-checkboxes-option1']" element + And I should see an ".form-checkbox.form-boolean.form-boolean--type-checkbox" element + And I should see an "[name='checkboxes[option2]']" element + And I should see an "[id='edit-checkboxes-option2']" element + And I should see an ".form-checkbox.form-boolean.form-boolean--type-checkbox" element + And I should see an "[name='checkboxes[option3]']" element + And I should see an "[id='edit-checkboxes-option3']" element + And I should see an ".form-checkbox.form-boolean.form-boolean--type-checkbox" element + + # Datelist (datelist) + And I should see an "[name='datelist[year]']" element + And I should see an "[id='edit-datelist-year']" element + And I should see an ".form-select.form-element.form-element--type-select" element + And I should see an "[name='datelist[month]']" element + And I should see an "[id='edit-datelist-month']" element + And I should see an ".form-select.form-element.form-element--type-select" element + And I should see an "[name='datelist[day]']" element + And I should see an "[id='edit-datelist-day']" element + And I should see an ".form-select.form-element.form-element--type-select" element + And I should see an "[name='datelist[hour]']" element + And I should see an "[id='edit-datelist-hour']" element + And I should see an ".form-select.form-element.form-element--type-select" element + And I should see an "[name='datelist[minute]']" element + And I should see an "[id='edit-datelist-minute']" element + And I should see an ".form-select.form-element.form-element--type-select" element + + # Datetime (datetime) + And I should see an "[name='datetime[date]']" element + And I should see an "[id='edit-datetime-date']" element + And I should see an ".form-date.form-element.form-element--type-date" element + And I should see an "[name='datetime[time]']" element + And I should see an "[id='edit-datetime-time']" element + And I should see an ".form-time.form-element.form-element--type-time" element + + # Email (email) + And I should see an "[name='email']" element + And I should see an "[id='edit-email']" element + And I should see an ".form-email.form-element.form-element--type-email" element + + # Entity Autocomplete (entity_autocomplete) + And I should see an "[name='entity_autocomplete']" element + And I should see an "[id='edit-entity-autocomplete']" element + And I should see an ".form-autocomplete.form-text.form-element.form-element--type-text" element + + # File (file) + And I should see an "[name='files[file]']" element + And I should see an "[id='edit-file']" element + And I should see an ".form-file.form-element.form-element--type-file" element + + # Image Button (image_button) + And I should see an "[name='op'][type='image']" element + And I should see an "[id='edit-1--2']" element + And I should see an "[src='/themes/contrib/civictheme/assets/icons/download.svg']" element + + # Linkit (linkit) + And I should see an "[name='linkit']" element + And I should see an "[id='edit-linkit']" element + And I should see an ".form-text.form-element.form-element--type-text" element + + # Machine Name (machine_name) + And I should see an "[name='machine_name']" element + And I should see an "[id='edit-machine-name']" element + And I should see an ".form-text.required.form-element.form-element--type-text" element + + # Number (number) + And I should see an "[name='number']" element + And I should see an "[id='edit-number']" element + And I should see an ".form-number.form-element.form-element--type-number" element + + # Password (password) + And I should see an "[name='password']" element + And I should see an "[id='edit-password']" element + And I should see an ".form-text.form-element.form-element--type-password" element + + # Password Confirm (password_confirm) + And I should see an "[name='password_confirm[pass1]']" element + And I should see an "[id='edit-password-confirm-pass1']" element + And I should see an ".form-text.form-element.form-element--type-password" element + And I should see an "[name='password_confirm[pass2]']" element + And I should see an "[id='edit-password-confirm-pass2']" element + And I should see an ".form-text.form-element.form-element--type-password" element + + # Path (path) + And I should see an "[name='path']" element + And I should see an "[id='edit-path']" element + And I should see an ".form-text.form-element.form-element--type-text" element + + # Radio (radio) + And I should see an "[name='radio']" element + And I should see an "[id='edit-radio']" element + And I should see an ".form-radio.form-boolean.form-boolean--type-radio" element + + # Radios (radios) + And I should see an "[name='radios']" element + And I should see an "[id='edit-radios-option1']" element + And I should see an ".form-radio.form-boolean.form-boolean--type-radio" element + And I should see an "[name='radios']" element + And I should see an "[id='edit-radios-option2']" element + And I should see an ".form-radio.form-boolean.form-boolean--type-radio" element + And I should see an "[name='radios']" element + And I should see an "[id='edit-radios-option3']" element + And I should see an ".form-radio.form-boolean.form-boolean--type-radio" element + + # Range (range) + And I should see an "[name='range']" element + And I should see an "[id='edit-range']" element + And I should see an ".form-range" element + + # Search (search) + And I should see an "[name='search']" element + And I should see an "[id='edit-search']" element + And I should see an ".form-search.form-element.form-element--type-search" element + + # Select (select) + And I should see an "[name='select']" element + And I should see an "[id='edit-select']" element + And I should see an ".form-select.form-element.form-element--type-select" element + + # Submit (submit) + And I should see an "[name='op'][type='submit']" element + And I should see an "[id='edit-1--3']" element + And I should see an ".button.js-form-submit.form-submit" element + + # Table (table) + And I should see an "[id='edit-table']" element + And I should see an ".responsive-enabled" element + + # Tel (tel) + And I should see an "[name='tel']" element + And I should see an "[id='edit-tel']" element + And I should see an ".form-tel.form-element.form-element--type-tel" element + + # Textarea (textarea) + And I should see an "[name='textarea']" element + And I should see an "[id='edit-textarea']" element + And I should see an ".form-textarea.resize-vertical.form-element.form-element--type-textarea" element + + # Textfield (textfield) + And I should see an "[name='textfield']" element + And I should see an "[id='edit-textfield']" element + And I should see an ".form-text.form-element.form-element--type-text" element + + # Url (url) + And I should see an "[name='url']" element + And I should see an "[id='edit-url']" element + And I should see an ".form-url.form-element.form-element--type-url" element + + # Weight (weight) + And I should see an "[name='weight']" element + And I should see an "[id='edit-weight']" element + And I should see an ".form-select.form-element.form-element--type-select" element + + # Markup within a form + And I should see the text "Markup within a form" + And I should see the text "Test content 1" + And I should see the text "List Item 1" + And I should see the text "List Item 2" + And I should see the text "List Item 3" + And I should see the link "Examples" with "https://www.drupal.org/docs/8/api/form-api/examples" diff --git a/tests/behat/features/form_elements.webform_form_elements.feature b/tests/behat/features/form_elements.webform_form_elements.feature new file mode 100644 index 000000000..627315847 --- /dev/null +++ b/tests/behat/features/form_elements.webform_form_elements.feature @@ -0,0 +1,265 @@ +@p1 @civictheme @civictheme_form_updates @civictheme_webform +Feature: Test a sample of the webform elements in the webform + + @api + Scenario: Fields appear as expected + Given I am an anonymous user + When I visit "form/civictheme-test-webform-fields" + + Then I should see "Civictheme Test Webform - Fields" in the ".ct-banner__title" element + + # Checkbox (checkbox) + And I should see an "[name='checkbox']" element + And I should see an "[id='edit-checkbox']" element + And I should see an ".ct-checkbox.ct-theme-light.ct-field__control" element + And I should see an ".form-checkbox" element + + # Text field (textfield) + And I should see an "[name='text_field']" element + And I should see an "[id='edit-text-field']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control" element + And I should see an ".form-text" element + + # Radio buttons (select_to_display_textarea) + And I should see an "[name='select_to_display_textarea']" element + And I should see an "[id='edit-select-to-display-textarea-Display-textarea']" element + And I should see an "[id='edit-select-to-display-textarea-Do-not-display-textarea']" element + And I should see an ".ct-radio.ct-theme-light.ct-field__control" element + + # Textarea (textarea) + And I should see an "[name='textarea']" element + And I should see an "[id='edit-textarea']" element + And I should see an ".ct-textarea.ct-theme-light.ct-field__control" element + + # Checkbox to display textfield (checkbox_visible_text_field_1) + And I should see an "[name='checkbox_visible_text_field_1']" element + And I should see an "[id='edit-checkbox-visible-text-field-1']" element + And I should see an ".ct-checkbox.ct-theme-light.ct-field__control.form-checkbox" element + + # Text field 1 (text_field_1) + And I should see an "[name='text_field_1']" element + And I should see an "[id='edit-text-field-1']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text" element + + # Autocomplete (autocomplete) + And I should see an "[name='autocomplete']" element + And I should see an "[id='edit-autocomplete']" element + And I should see an ".js-form-item.form-item.js-form-type-webform-autocomplete.form-item-autocomplete.js-form-item-autocomplete" element + + # Color (color) + And I should see an "[name='color']" element + And I should see an "[id='edit-color']" element + And I should see an ".ct-field.ct-theme-light.ct-field--color.ct-field--vertical.form-item.js-form-item.js-form-type-color.form-type-color.form-type--color.js-form-item-color.form-item-color.form-item--color" element + + # Email (email) + And I should see an "[name='email']" element + And I should see an "[id='edit-email']" element + And I should see an ".ct-field.ct-theme-light.ct-field--email.ct-field--vertical.form-item.js-form-item.js-form-type-email.form-type-email.form-type--email.js-form-item-email.form-item-email.form-item--email" element + + # Email confirm (email_confirm) + And I should see an "[name='email_confirm[mail_1]']" element + And I should see an "[id='edit-email-confirm-mail-1']" element + And I should see an ".ct-field.ct-theme-light.ct-field--email.ct-field--vertical.form-item.js-form-item.js-form-type-email.form-type-email.form-type--email.js-form-item-email-confirm-mail-1.form-item-email-confirm-mail-1.form-item--email-confirm-mail-1" element + And I should see an "[name='email_confirm[mail_2]']" element + And I should see an "[id='edit-email-confirm-mail-2']" element + And I should see an ".ct-field.ct-theme-light.ct-field--email.ct-field--vertical.form-item.js-form-item.js-form-type-email.form-type-email.form-type--email.js-form-item-email-confirm-mail-2.form-item-email-confirm-mail-2.form-item--email-confirm-mail-2" element + + # Email multiple (email_multiple) + And I should see an "[name='email_multiple']" element + And I should see an "[id='edit-email-multiple']" element + And I should see an ".js-form-item.form-item.js-form-type-webform-email-multiple.form-item-email-multiple.js-form-item-email-multiple" element + + # Number (number) + And I should see an "[name='number']" element + And I should see an "[id='edit-number']" element + And I should see an ".ct-field.ct-theme-light.ct-field--number.ct-field--vertical.form-item.js-form-item.js-form-type-number.form-type-number.form-type--number.js-form-item-number.form-item-number.form-item--number" element + + # Number - Max 10 - Min 4 (number_max_10_min_4) + And I should see an "[name='number_max_10_min_4']" element + And I should see an "[id='edit-number-max-10-min-4']" element + And I should see an ".ct-field.ct-theme-light.ct-field--number.ct-field--vertical.form-item.js-form-item.js-form-type-number.form-type-number.form-type--number.js-form-item-number-max-10-min-4.form-item-number-max-10-min-4.form-item--number-max-10-min-4" element + + # Range (range) + And I should see an "[name='range']" element + And I should see an "[id='edit-range']" element + And I should see an ".js-form-item.form-item.js-form-type-range.form-item-range.js-form-item-range" element + + # Range Min 10 Max 100 Steps 10 (range_min_10_max_100_steps_10) + And I should see an "[name='range_min_10_max_100_steps_10']" element + And I should see an "[id='edit-range-min-10-max-100-steps-10']" element + And I should see an ".js-form-item.form-item.js-form-type-range.form-item-range-min-10-max-100-steps-10.js-form-item-range-min-10-max-100-steps-10" element + + # Rating (rating) + And I should see an "[name='rating']" element + And I should see an "[id='edit-rating']" element + And I should see an ".js-form-item.form-item.js-form-type-webform-rating.form-item-rating.js-form-item-rating" element + + # Telephone (telephone) + And I should see an "[name='telephone']" element + And I should see an "[id='edit-telephone']" element + And I should see an ".ct-field.ct-theme-light.ct-field--tel.ct-field--vertical.form-item.js-form-item.js-form-type-tel.form-type-tel.form-type--tel.js-form-item-telephone.form-item-telephone.form-item--telephone" element + + # Terms of service (terms_of_service) + And I should see an "[name='terms_of_service']" element + And I should see an "[id='edit-terms-of-service']" element + And I should see an ".ct-field.ct-theme-light.ct-field--checkbox.ct-field--vertical.form-type-webform-terms-of-service.js-form-type-webform-terms-of-service.form-item.js-form-item.js-form-type-checkbox.form-type-checkbox.form-type--checkbox.js-form-item-terms-of-service.form-item-terms-of-service.form-item--terms-of-service" element + + # URL (url) + And I should see an "[name='url']" element + And I should see an "[id='edit-url']" element + And I should see an ".ct-field.ct-theme-light.ct-field--url.ct-field--vertical.form-item.js-form-item.js-form-type-url.form-type-url.form-type--url.js-form-item-url.form-item-url.form-item--url" element + + # Address (address) + And I should see an "[name='address[address]']" element + And I should see an "[id='edit-address-address']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='address[address_2]']" element + And I should see an "[id='edit-address-address-2']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='address[city]']" element + And I should see an "[id='edit-address-city']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='address[state_province]']" element + And I should see an "[id='edit-address-state-province']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select.form-element.form-element--type-select.form-element--api-select.form-control" element + + And I should see an "[name='address[postal_code]']" element + And I should see an "[id='edit-address-postal-code']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='address[country]']" element + And I should see an "[id='edit-address-country']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select.form-element.form-element--type-select.form-element--api-select.form-control" element + + # Contact (contact) + And I should see an "[name='contact[name]']" element + And I should see an "[id='edit-contact-name']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='contact[company]']" element + And I should see an "[id='edit-contact-company']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='contact[email]']" element + And I should see an "[id='edit-contact-email']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-email.form-element.form-element--type-email.form-element--api-email.form-control" element + + And I should see an "[name='contact[phone]']" element + And I should see an "[id='edit-contact-phone']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-tel.form-element.form-element--type-tel.form-element--api-tel.form-control" element + + And I should see an "[name='contact[address]']" element + And I should see an "[id='edit-contact-address']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='contact[address_2]']" element + And I should see an "[id='edit-contact-address-2']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='contact[city]']" element + And I should see an "[id='edit-contact-city']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='contact[state_province]']" element + And I should see an "[id='edit-contact-state-province']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select.form-element.form-element--type-select.form-element--api-select.form-control" element + + And I should see an "[name='contact[postal_code]']" element + And I should see an "[id='edit-contact-postal-code']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='contact[country]']" element + And I should see an "[id='edit-contact-country']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select.form-element.form-element--type-select.form-element--api-select.form-control" element + + # Link (link) + And I should see an "[name='link[title]']" element + And I should see an "[id='edit-link-title']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='link[url]']" element + And I should see an "[id='edit-link-url']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-url.form-element.form-element--type-url.form-element--api-url.form-control" element + + # Name (name) + And I should see an "[name='name[title][select]']" element + And I should see an "[id='edit-name-title-select']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-element.form-element--type-select.form-element--api-select.form-control" element + + And I should see an "[name='name[first]']" element + And I should see an "[id='edit-name-first']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='name[middle]']" element + And I should see an "[id='edit-name-middle']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='name[last]']" element + And I should see an "[id='edit-name-last']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='name[suffix]']" element + And I should see an "[id='edit-name-suffix']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + And I should see an "[name='name[degree]']" element + And I should see an "[id='edit-name-degree']" element + And I should see an ".ct-textfield.ct-theme-light.ct-field__control.form-text.form-element.form-element--type-textfield.form-element--api-textfield.form-control" element + + # Telephone advanced (telephone_advanced) + And I should see an "[name='telephone_advanced[type]']" element + And I should see an "[id='edit-telephone-advanced-type']" element + And I should see an ".ct-select.ct-theme-light.ct-field__control.form-select.form-element.form-element--type-select.form-element--api-select.form-control" element + + And I should see an "[name='telephone_advanced[phone]']" element + And I should see an "[id='edit-telephone-advanced-phone']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.js-webform-telephone-international.webform-webform-telephone-international.form-tel.form-element.form-element--type-tel.form-element--api-tel.form-control" element + + And I should see an "[name='telephone_advanced[ext]']" element + And I should see an "[id='edit-telephone-advanced-ext']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-number.form-element.form-element--type-number.form-element--api-number.form-control" element + # Audio file + And I should see an "[name='files[audio_file]']" element + And I should see an "[id='edit-audio-file-upload']" element + And I should see an ".ct-button.ct-theme-light.ct-button--primary.ct-button--submit.ct-button--regular.js-hide.button.js-form-submit.form-submit" element + + # Document file + And I should see an "[name='files[document_file]']" element + And I should see an "[id='edit-document-file-upload']" element + And I should see an ".ct-button.ct-theme-light.ct-button--primary.ct-button--submit.ct-button--regular.js-hide.button.js-form-submit.form-submit" element + + # File + And I should see an "[name='files[file]']" element + And I should see an "[id='edit-file-upload']" element + And I should see an ".ct-button.ct-theme-light.ct-button--primary.ct-button--submit.ct-button--regular.js-hide.button.js-form-submit.form-submit" element + + # Image file + And I should see an "[name='files[image_file]']" element + And I should see an "[id='edit-image-file-upload']" element + And I should see an ".ct-button.ct-theme-light.ct-button--primary.ct-button--submit.ct-button--regular.js-hide.button.js-form-submit.form-submit" element + + # Video file + And I should see an "[name='files[video_file]']" element + And I should see an "[id='edit-video-file-upload']" element + And I should see an ".ct-button.ct-theme-light.ct-button--primary.ct-button--submit.ct-button--regular.js-hide.button.js-form-submit.form-submit" element + # Date (date) + And I should see an "[name='date']" element + And I should see an "[id='edit-date']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-date" element + + # Date/time (date_time) + And I should see an "[name='date_time[date]']" element + And I should see an "[id='edit-date-time-date']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-date" element + And I should see an "[name='date_time[time]']" element + And I should see an "[id='edit-date-time-time']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control.form-time" element + + # Entity autocomplete (entity_autocomplete) + And I should see an "[name='entity_autocomplete']" element + And I should see an "[id='edit-entity-autocomplete']" element + And I should see an ".ct-input.ct-theme-light.ct-field__control" element + And I should see an ".form-autocomplete.form-text.form-element.form-element--type-entity_autocomplete.form-element--api-entity_autocomplete.form-control" element diff --git a/web/modules/custom/civictheme_dev/civictheme_dev.module b/web/modules/custom/civictheme_dev/civictheme_dev.module index 95a30f7cd..1bda0f600 100644 --- a/web/modules/custom/civictheme_dev/civictheme_dev.module +++ b/web/modules/custom/civictheme_dev/civictheme_dev.module @@ -39,10 +39,6 @@ function civictheme_dev_preprocess_html(array &$variables): void { * Implements hook_styleguide_alter(). */ function civictheme_dev_styleguide_alter(array &$items): void { - // Remove password_confirm field from the form as CivicTheme does not support - // it. - unset($items['form']['content']['password_confirm']); - _civictheme_dev_styleguide__form_test__textfield($items); _civictheme_dev_styleguide__form_test__textarea($items); _civictheme_dev_styleguide__form_test__select($items); diff --git a/web/modules/custom/civictheme_dev/civictheme_dev.routing.yml b/web/modules/custom/civictheme_dev/civictheme_dev.routing.yml new file mode 100644 index 000000000..3581f5c99 --- /dev/null +++ b/web/modules/custom/civictheme_dev/civictheme_dev.routing.yml @@ -0,0 +1,14 @@ +civictheme_dev.styleguide_form: + path: '/civictheme-core-form-elements' + defaults: + _form: 'Drupal\civictheme_dev\Form\CoreFormElementsForm' + _title: 'CivicTheme Core Form Elements Form' + requirements: + _permission: 'access content' +civictheme_dev.admin_styleguide_form: + path: '/admin/structure/civictheme-core-form-elements' + defaults: + _form: 'Drupal\civictheme_dev\Form\CoreFormElementsForm' + _title: 'Core Form Elements Form (Admin Theme)' + requirements: + _permission: 'view the administration theme' diff --git a/web/modules/custom/civictheme_dev/config/install/webform.webform.civictheme_test_webform_fields.yml b/web/modules/custom/civictheme_dev/config/install/webform.webform.civictheme_test_webform_fields.yml new file mode 100644 index 000000000..037263cca --- /dev/null +++ b/web/modules/custom/civictheme_dev/config/install/webform.webform.civictheme_test_webform_fields.yml @@ -0,0 +1,383 @@ +langcode: en +status: open +dependencies: { } +weight: 0 +open: null +close: null +uid: 1 +template: false +archive: false +id: civictheme_test_webform_fields +title: 'Civictheme Test Webform - Fields' +description: '
This form will be used to test the available webform fields, including conditional form elements.
' +categories: { } +elements: |- + basic_elements_container: + '#type': container + checkbox: + '#type': checkbox + '#title': Checkbox + hidden: + '#type': hidden + '#title': Hidden + text_field: + '#type': textfield + '#title': 'Text field' + conditional_container: + '#type': container + select_to_display_textarea: + '#type': radios + '#title': 'Select to display textarea' + '#options': + 'Display textarea': 'Display textarea' + 'Do not display textarea': 'Do not display textarea' + textarea: + '#type': textarea + '#title': Textarea + '#states': + visible: + ':input[name="checkbox_visible_text_field_1"]': + checked: true + checkbox_visible_text_field_1: + '#type': checkbox + '#title': 'Check to display textfield' + text_field_1: + '#type': textfield + '#title': 'Text field 1' + '#states': + visible: + ':input[name="checkbox_visible_text_field_1"]': + checked: true + advanced_elements_container: + '#type': container + autocomplete: + '#type': webform_autocomplete + '#title': Autocomplete + '#autocomplete_items': gender + color: + '#type': color + '#title': Color + email: + '#type': email + '#title': Email + email_confirm: + '#type': webform_email_confirm + '#title': 'Email confirm' + '#confirm__title': 'Email confirm title - Test' + '#confirm__description': 'Email confirm description - test
' + '#confirm__placeholder': 'Email confirm placeholder- Test' + email_multiple: + '#type': webform_email_multiple + '#title': 'Email multiple' + number: + '#type': number + '#title': Number + number_max_10_min_4: + '#type': number + '#title': 'Number - Max 10 - Min 4' + '#min': 4 + '#max': 10 + range: + '#type': range + '#title': Range + range_min_10_max_100_steps_10: + '#type': range + '#title': 'Range Min 10 Max 100 Steps 10' + '#min': 10 + '#step': 10 + rating: + '#type': webform_rating + '#title': Rating + telephone: + '#type': tel + '#title': Telephone + terms_of_service: + '#type': webform_terms_of_service + '#terms_title': 'Terms of service' + '#terms_content': 'Terms of service test content
' + url: + '#type': url + '#title': URL + composite_elements_container: + '#type': container + address: + '#type': webform_address + '#title': Address + contact: + '#type': webform_contact + '#title': Contact + link: + '#type': webform_link + '#title': Link + name: + '#type': webform_name + '#title': Name + telephone_advanced: + '#type': webform_telephone + '#title': 'Telephone advanced' + markup_container: + '#type': container + advanced_html_text: + '#type': processed_text + '#text': "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Test content 1