Support for webform_term_select element

Created on 19 August 2020, over 4 years ago
Updated 6 April 2023, over 1 year ago

Attached patch adds support for the webform module.
After applying a cshs term reference field is available for use in any webform.

There is 1 small issue which I wasn't able to resolve in the proper way. The webform element seems to render a completely empty option and that trips up the jquery simpeler-select. I have written a check and removal in template_preprocess_cshs_select().
Perhaps someone else can have a look at this and fix it properly. For now it will work.

✨ Feature request
Status

Needs review

Version

4.0

Component

Code

Created by

🇧🇪Belgium weseze

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.

  • 🇧🇪Belgium weseze

    @greatmatter: I've updated the patch for version 4 by returing an empty string instead of NULL and updating the functions signature.

    @jdearie: I think it should be possible, since cshs allows this (I think). However I have not implemented most of the features cshs offers in the webform element, because it is way out of scope for my client...

  • 🇺🇸United States greatmatter

    It appears the latest Webform RC has broken this--I'm not entirely sure why, however...

  • 🇺🇸United States johnnydarkko

    Using the patch in #11, I'm now seeing the option to use CSHS:

    I was expecting to find some extra settings here, but nothing else shows up--I think this is where my issue is originating. Where should I be finding the CSHS options?

    After enabling CSHS, I get a few PHP warnings when viewing the webform:

    Warning: Undefined array key "hierarchy_depth" in Drupal\cshs\CshsWebformHelper->formElement() (line 297 of modules/contrib/cshs/src/CshsOptionsFromHelper.php).
    Warning: Undefined array key "save_lineage" in Drupal\cshs\CshsWebformHelper->formElement() (line 306 of modules/contrib/cshs/src/CshsOptionsFromHelper.php).
    Warning: Undefined array key "force_deepest" in Drupal\cshs\CshsWebformHelper->formElement() (line 309 of modules/contrib/cshs/src/CshsOptionsFromHelper.php).
    Warning: Undefined array key "required_depth" in Drupal\cshs\CshsWebformHelper->formElement() (line 310 of modules/contrib/cshs/src/CshsOptionsFromHelper.php).

    I also get a javascript error when I try to load the webform:

    Uncaught TypeError: $(...).once is not a function
        attach cshs.ts:14
        attachBehaviors drupal.js:166
        attachBehaviors drupal.js:162
        <anonymous> drupal.init.js:32
        listener drupal.init.js:20
        domReady drupal.init.js:26
        <anonymous> drupal.init.js:31
        <anonymous> drupal.init.js:34

    I found that the settings array is empty:

    Additional details:
    Drupal 10.1.6
    PHP 8.1.18
    CSHS 4.0.0
    Theme: Tara →

  • 🇺🇸United States jdearie

    I wanted to come back and post the answer to my question - in case others were trying to do the same.

    I need to store the full hierarchy of the term select with cshs widget. None of the options in the Item format options in the Submission Display field worked.

    After much much research, I discovered {{ item.breadcrumb }}

    That token stores the full path. I also updated the Custom Settings / Custom properties. By default, the save_lineage is set to false, so I set it to true. I'm not actually sure I needed to do that last part or not, but I did.

    1. Click the Advanced tab on the element you wish to edit
    2. Expand the SUBMISSION DISPLAY fieldset.
    3. Select Custom... from the Item format field in the SINGLE ITEM fieldset.
    4. Type {{ item.breadcrumb }} in the Item format custom HTML field
    5. Scroll down to CUSTOM SETTINGS and set the save lineage to true: save_lineage: true
  • 🇺🇾Uruguay santiagotrindade

    @johnnydarkko, I’m not sure if you’ve found a solution, but in my case, I didn’t need those fields, so I resolved the issue by merging the `$settings` with the default settings. I’m not creating a patch for this, as it’s probably not the best solution and may not address the issue in the long term. However, it helped me avoid those warnings:

    - $settings = $this->getSettings(); 
    + $settings = $this->getSettings() + self::defaultSettings(); 
Production build 0.71.5 2024