Closed (outdated)
Project:
Webform
Version:
8.x-5.0-beta15
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
25 Jul 2017 at 07:50 UTC
Updated:
19 Jun 2019 at 17:47 UTC
Jump to comment: Most recent
Comments
Comment #2
jrockowitz commentedPlease export and upload an example of the problem.
Comment #3
simohell commentedHere is an example. Is the YAML enough?
Single select, radio buttons and checkboxes work.
Multiple select with these settings appears initially but is hidden when any value is chosen and remains hidden when no value is chosen again. Is there a syntax that would work for multiple select?
Comment #4
jrockowitz commentedThere is a core issue #1149078: States API doesn't work with multiple select fields and the Webform UI does not support this functionality.
We are blocked until this functionality is fixed in Drupal core.
Comment #5
jrwest_webguy commentedI think I might be running into this old issue. Can anyone confirm that this is still a problem for Webforms?
I have a multi-page form. On page two I have conditional logic applied to a 'Fieldset'. The elements within the 'Fieldset' include one 'Select' element, a 'Markup/HTML' element, a 'Radio' button with 2 possible values, and a 'Textfield'. The Select element and Textfield have additional Conditional logic applied to them, even though they exist within the 'Fieldset'. I've tried to move them outside of the Fieldset; however -- I think because I'm still within the 'Page' element' -- I'm still getting an error. The error is (paraphrasing), "An illegal choice has been made. Contact an Admin."
I'm currently running 8.x-5.2, which I really like because now I can email file attachments! :) But, the logic on this one form which is kinda important is now the bane of my existence.
Comment #6
jrockowitz commented@jwest1@eastern.edu I am not sure your issue is related
If possible you should create an isolated example that can be used to replicate your specific issue?
Comment #7
jrwest_webguy commented@jrockowitz I’m not sure what you’re suggesting I do. Please clarify.
Comment #8
jrockowitz commentedCreate a simple webform that replicates the problem described in #5, export it, and attach it here.
Comment #9
jrwest_webguy commentedThis is not a simple webform. It is a very complex webform built using your heretofore excellent Webform module for Drupal 8. As far as I know, we were not having any problems with it until we updated to Webforms 8.x-5.2, I believe I was at 8.x-5.0 before. Here is an example of the code I'm trying to use:
Comment #10
jrockowitz commentedIt is not reasonable to expect me to debug your custom webform. Please isolate the problem to a generic example.
Comment #11
jrwest_webguy commentedThis is not a 'custom' webform. It is created solely from the elements and features provided by the Webform module for Drupal 8. I have trimmed the code down to just an example of the 'Page 2' logic; and I removed the cumbersome Flexbox layout elements. I am not asking you to fix my form. I'm simply asking you to look into why this form no longer works using the Webform module, where in the past it has.
Comment #12
jrockowitz commentedThe below element is causing this issue.
The '#default_value': None is triggering the "An illegal choice has been detected. Please contact the site administrator." error because "None" is not listed in #options.
Comment #13
jrwest_webguy commentedThank you, Jacob. So, now I have a few more questions, if I may pick your brain. Can you elaborate on how you found this was the cause of the error? Did you use some kind of logging tool, web browser console utility, or just by reading the code?
Comment #14
jrockowitz commentedThe #default_value of 'None' is not a valid option which triggers \Drupal\Core\Form\FormValidator::performRequiredValidation
For example, the below simplified element with trigger the validation error when no radio is selected.
Comment #15
jrockowitz commentedComment #16
jrwest_webguy commentedI would have never found that in a million millennia . . . I just looked at another Radio button element, and it has no '#default_value' line assigned to it; which tells me that #default_value is not required. So, I'm not even sure how it got in there . . . Anyway, thank you very much, again!
Guess this should have been in a separate issue? Is the ORIGINAL "StateAPI and multiple select fields" issue still prevalent in Drupal Core, or, more importantly, still a blocker for future Webform enhancements?
Comment #17
jrockowitz commentedOriginal issue is still in core.
Comment #18
jrockowitz commentedComment #19
mhentry commentedHi I am using Entity check boxes referencing taxonomy items. I want to create a condition with checkbox entity. Eg. let say my taxonomy has 5 items. A,B,C,D,E. I want to create a condition that when user select option B, they cant choose C,D and E. I could not know how to do a condition within entity checkbox. Any suggestions helpful.
Comment #20
jrockowitz commentedYou will most likely will have to write some custom JavaScript accomplish this behavior.
Comment #21
mhentry commentedThank you for the reply. This is my YAML for entity checkbox, how do I get the value of each
delivery_options:
'#type': entity_checkboxes
'#title': 'Delivery Options'
'#target_type': taxonomy_term
'#selection_handler': 'default:taxonomy_term'
'#selection_settings':
target_bundles:
borrower_delivery_options: borrower_delivery_options
sort:
field: name
direction: ASC
Any examples on how to create custom JavaScript code code
(function($) {
$(document).ready(function() {
$('#delivery_options[4]').change(function() {
switch ($(this).val()) {
case '1':
$('#delivery_options[1]').hide();
break;
default:
$('#delivery_options[2]').show();
break;
}
});
});
}) (jQuery);
Comment #22
jrockowitz commented@mhentry Please move this question/issue to https://drupal.stackexchange.com/questions/tagged/webforms
Comment #23
mhentry commented@jrockowitz I moved it.
Comment #24
jrockowitz commented