Utilizing the Client-side hierarchical select module in conjunction with the Conditional Fields module doesn't work in its current state. The form states do not recognize the values in the CSHS element/widget.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | cshs-conditional_fields-3150700-21.diff | 1.93 KB | sarathkm |
Issue fork cshs-3150700
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3150700-conditional-fields-integration
compare
- 4.0.x
changes, plain diff MR !16 /
changes, plain diff MR !14 /
changes, plain diff MR !15
Comments
Comment #2
kerasai commentedAttached is a patch that adds a
ConditionalFieldsHandlerplugin to allow conditional fields to properly apply states to the element/widget.Comment #3
kerasai commentedUploaded a new patch to address an issue with applying the states on initial form load. For whatever reason the states were being ignored when loading the form under conditions where states should hide/disable/etc.
I'm not in love with the solution, but it changes the original element's value and resets it as the jQuery plugin is applied in order to trigger the initial states handling.
Comment #4
heikkiy commentedIt seems like the latest patch is not compatible with the recommended version 3.4.
Comment #5
kerasai commented@HeikkiY, that is probably correct. This change applies to the1.x branch, I'm currently running 8.x-1.7.
Comment #6
kerasai commentedRe-rolled for 3.x version.
This change is only the conditional fields plugin. The wonky JS is no longer needed.
Comment #7
heikkiy commentedI tested this with the latest 4.0.0 release. Patch applies cleanly the field formatter seems to work fine.
Comment #8
heikkiy commentedComment #9
mayela commentedI tested patch #3 with Drupal 10.1.4 and cshs 4.0 and I am getting this error:
AssertionError: assert(!\array_key_exists($element['#none_value'], $element['#options'])) in assert() (line 64 of modules/contrib/cshs/src/Element/CshsElement.php)
I get the error when I try to add a condition between two fields , field 1: Document Type ( cshs ) and Field 2: Lab Document Type ( Select list )
The condition I am trying to set is that if field 1 has the value of option: Laboratories , show Lab Document Type field
Comment #10
mayela commentedI was able to fix the assertion error by checking if the key specified by $element['#none_value'] exists in the array $element['#options']. If it doesn't exist, the code inside the if block will be executed.
Added this to line 64 to cshs/src/Element/CshsElement.php file
Comment #11
sarathkmFacing issue with AssertionError: assert(!\array_key_exists($element['#none_value'], $element['#options'])) in assert() (line 64 of /var/www/html/web/modules/contrib/cshs/src/Element/CshsElement.php)
Comment #12
sarathkmComment #14
sarathkmFixes AssertError for Conditional Field
Comment #15
sarathkmComment #16
sarathkmComment #21
sarathkmComment #22
danharper commentedI'm facing this issue using the field_states_ui module.
The showing and hiding just doesn't seem to work even with the latest patch.
Comment #23
joseph.olstad@danharper, you'll want to rebuild cache after applying any patch.
Comment #26
joseph.olstadComment #28
sarathkmHi @joseph.olstad,
I am not sure why, but I don't see this Issue credit being added to any of the contributor.
Comment #29
joseph.olstadHi, for some reason d.o removed the author suggestion from the issues.
With that said, multiple contributors are being credited, including sarathkm see below:
Issue #3150700 by sarathkm, kerasai, HeikkiY, mayela: Conditional Fields Integration