Answers.Body: <p>I would retype from CiviCRM Options -&gt; Checkboxes. Then not only are conditionals way easier, you will also get some nice layout options -&gt; e.g. 2 columns or 3 columns.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-05T09:42:46.657Z
Answers.Text: HI Karin - Many thanks.  Just to be sure, you mean you mean change the actual type in the YAML source from 'civicrm_options' to 'checkboxes'.  I ask as you cannot add an element using the Webform module called 'checkboxes', you only get 'tableselect'. The Form API has this but I'll be honest and do not understand the difference between the two.  It is good to know that these types can be changed without distructive changes to CiviCRM data
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-07T13:52:47.823Z
Answers.Text: You can actually just hit Edit on the element and then re-type from CiviCRM Options -> to Checkboxes [most common re-typing are available via the UI].
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-07T13:54:54.157Z
Answers.Text: That really helpful Karin  - many thanks, I'll give it a go
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-04T20:30:48.433Z
Answers.LastActivityDate: 2023-07-04T20:30:48.433Z
Answers.UserDisplayName: KarinG - Semper IT
Body: <p>I am converting some D7 forms and came across a problem this week with adding conditionals.  On one form, I display a text field if one of a set of 8 check boxes is checked.  It's the common form usecase to collect more information if the 'Other' choice is also selected.</p>
  <p><a href="https://i.sstatic.net/kxW3R.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/kxW3R.png" alt="enter image description here" /></a></p>
  <p>When this is added to the webform automatically it is added as type 'civicrm_options'.  To add a conditional, I went to the text field and selected that I wanted it to be Visible if the 'Other' option was selected:
  <a href="https://i.sstatic.net/bxxFk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bxxFk.png" alt="enter image description here" /></a></p>
  <p>Try as I might I could not get this to fire.  I made a test 'Table Select' element to see if I could mimic the behaviour and it worked fine...  Looking a the source of the condition, the penny dropped:</p>
  <p>This is the source that is produced by following what the UI allows you:</p>
  <pre><code> visible:
    ':input[name=&quot;civicrm_1_case_1_cg43_custom_426&quot;]':
      value: '6'
  </code></pre>
  <p>This is the source that I got from my test Table select element:</p>
  <pre><code> visible:
    ':input[name=&quot;choice_multi[4]&quot;]':
      checked: true
  </code></pre>
  <p>So the work around for me was to add the same syntax:</p>
  <pre><code>visible:
    ':input[name=&quot;civicrm_1_case_1_cg43_custom_426[6]&quot;]':
      checked: true
  </code></pre>
  <p>This gives you this final result when it is viewed through the UI:</p>
  <p><a href="https://i.sstatic.net/r4iGY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/r4iGY.png" alt="enter image description here" /></a></p>
  <p>It perhaps should have been obvious, but maybe just an issue with the Webform CiviCRM integration.  Anywway, I hope this helps others!</p>
  <p><strong>An open question</strong> - I tried changing the type of my CiviCRM element from <strong>civicrm_options</strong> to <strong>tableselect</strong>.  It all seemed to work fine and values seemed to save OK.  I am nervous about making those sorts of changes as it is only possible to do this sort of thing through the build YAML source.  If it not dangerous, it might be far easier as then you get a far easier interface to do the conditionals.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-08T14:34:10.073Z
Comments.Text: Great work! I needed this today, thanks so much!
Comments.UserDisplayName: dtw
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-10T15:59:58.283Z
Comments.Text: Cheers, but but check out KatinG's comment re changing the type to checkboxes as you may find this neater!
Comments.UserDisplayName: ChumKui
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-12T07:44:47.767Z
Comments.Text: I did do that on a few fields but "CiviCRM Options" (I think) is dynamically linked to the dbase, so will reflect any new options added. Switching to checkboxes becomes a static list, which is not always ideal.
Comments.UserDisplayName: dtw
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-20T13:24:03.000Z
Comments.Text: True, if you need them to dynamicaly update, you have to use CiviCRM Options.  I tend to version control on one set of options, but if you need it to update as CiviCRM options change, then yes my original solution is the best for you!
Comments.UserDisplayName: ChumKui
Tags: <webform-civicrm>
Title: Drupal Webform civicrm_options workaround for conditonal states
ThreadText: # Drupal Webform civicrm_options workaround for conditonal states
  
  (Asked by: username_0 on 2023-07-04)
  
  I am converting some D7 forms and came across a problem this week with adding conditionals.  On one form, I display a text field if one of a set of 8 check boxes is checked.  It's the common form usecase to collect more information if the 'Other' choice is also selected.
  
  When this is added to the webform automatically it is added as type 'civicrm_options'.  To add a conditional, I went to the text field and selected that I wanted it to be Visible if the 'Other' option was selected:
  
  Try as I might I could not get this to fire.  I made a test 'Table Select' element to see if I could mimic the behaviour and it worked fine...  Looking a the source of the condition, the penny dropped:
  This is the source that is produced by following what the UI allows you:
   visible:
    ':input[name="civicrm_1_case_1_cg43_custom_426"]':
      value: '6'
  
  This is the source that I got from my test Table select element:
   visible:
    ':input[name="choice_multi[4]"]':
      checked: true
  
  So the work around for me was to add the same syntax:
  visible:
    ':input[name="civicrm_1_case_1_cg43_custom_426[6]"]':
      checked: true
  
  This gives you this final result when it is viewed through the UI:
  
  It perhaps should have been obvious, but maybe just an issue with the Webform CiviCRM integration.  Anywway, I hope this helps others!
  An open question - I tried changing the type of my CiviCRM element from civicrm_options to tableselect.  It all seemed to work fine and values seemed to save OK.  I am nervous about making those sorts of changes as it is only possible to do this sort of thing through the build YAML source.  If it not dangerous, it might be far easier as then you get a far easier interface to do the conditionals.
  
  **Tags:** webform-civicrm
  
  > **Comments:**
  > **username_1**: Great work! I needed this today, thanks so much!  
  > **username_0**: Cheers, but but check out KatinG's comment re changing the type to checkboxes as you may find this neater!  
  > **username_1**: I did do that on a few fields but "CiviCRM Options" (I think) is dynamically linked to the dbase, so will reflect any new options added. Switching to checkboxes becomes a static list, which is not always ideal.  
  > **username_0**: True, if you need them to dynamicaly update, you have to use CiviCRM Options.  I tend to version control on one set of options, but if you need it to update as CiviCRM options change, then yes my original solution is the best for you!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-07-04. Score: 2 | Accepted answer
  
  I would retype from CiviCRM Options -> Checkboxes. Then not only are conditionals way easier, you will also get some nice layout options -> e.g. 2 columns or 3 columns.
  
  > **Comments:**
  > **username_0**: HI Karin - Many thanks.  Just to be sure, you mean you mean change the actual type in the YAML source from 'civicrm_options' to 'checkboxes'.  I ask as you cannot add an element using the Webform module called 'checkboxes', you only get 'tableselect'. The Form API has this but I'll be honest and do not understand the difference between the two.  It is good to know that these types can be changed without distructive changes to CiviCRM data  
  > **username_2**: You can actually just hit Edit on the element and then re-type from CiviCRM Options -> to Checkboxes [most common re-typing are available via the UI].  
  > **username_0**: That really helpful Karin  - many thanks, I'll give it a go  
  
  ---
  
  