Answers.Body: <p>I did it with javascript:</p>
  
  <p>CRM/Event/Form/Registration/Register.tpl (custom_209 is the custom field attached to the event configuration page, to show which accommodation options should be valid for this event, out of the field 209 which has ALL possibilities) -</p>
  
  <pre><code>&lt;div style="display:none;" id="event_accommodation"&gt;
      {crmAPI var='result' entity='Event' action='getsingle' return='custom_209' id=$event.id}
      {foreach from=$result.custom_209 item=value key=field}{$value},{/foreach}
  &lt;/div&gt;
  </code></pre>
  
  <p>And then in a custom .js file in the registration form itself:</p>
  
  <pre><code>const ID_HIDDEN_DIV_EVENT_ACCOMMODATION_VALID_OPTIONS = 'event_accommodation'; // This is set in the CRM/Event/Form/Registration/Register.tpl
  
  function hideInvalidAccommodationOptions()
  {
      if (jQuery("input[name='" + CUSTOM_FILED_EVENT_ACCOMMODATION + "']").length == 0)
      {
          // There is not accommodation field in this form. Could be an online course or a different type of seminar.
          return;
      }
  
      var validAccOptionsString = jQuery('#' + ID_HIDDEN_DIV_EVENT_ACCOMMODATION_VALID_OPTIONS).text().trim();
  
      if (validAccOptionsString.length == 0)
      {
          // No accommodation specification were set for this event
          return;
      }
  
      // Remove the last comma (,) from the string
      validAccOptionsString = validAccOptionsString.slice(0,-1);
  
      var validAccOptionsArr = validAccOptionsString.split(',');
      var accOptionsInputElementsArr = jQuery("input[name='" + CUSTOM_FILED_EVENT_ACCOMMODATION + "']");
  
      // Iterate through all possible accommodation input elements
      jQuery.each(accOptionsInputElementsArr, function(i, accOptionInputElement)
      {
          var $accOptionInput = jQuery(accOptionInputElement);
  
          // If the input element's value is not found in the specified event accommodation options
          if (jQuery.inArray($accOptionInput.attr("value"), validAccOptionsArr) == -1)
          {
              // Go up twice in the DOM from the input, to the td, to the tr, and remove the whole tr from the DOM.
              $accOptionInput.parent().parent().remove();
          }
      });
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-07T10:44:29.123Z
Answers.LastActivityDate: 2018-05-07T10:44:29.123Z
Answers.UserDisplayName: Elad
Answers.Body: <p>To do this via webform_civicrm</p>
  
  <p>Download and enable <a href="https://www.drupal.org/project/webform_civicrm" rel="nofollow noreferrer">webform_civicrm</a> and read the documentation. </p>
  
  <p>Google for some answers on SE or our blog at fuzion.co.nz/blog for some explanations about doing Events via webform_civicrm eg</p>
  
  <p><a href="https://www.fuzion.co.nz/blogs/registering-multiple-people-multiple-events" rel="nofollow noreferrer">https://www.fuzion.co.nz/blogs/registering-multiple-people-multiple-events</a></p>
  
  <p><a href="https://civicrm.stackexchange.com/questions/tagged/webform-civicrm">https://civicrm.stackexchange.com/questions/tagged/webform-civicrm</a></p>
  
  <p><a href="https://civicrm.stackexchange.com/questions/24578/how-can-i-create-early-bird-fees-with-webform-civicrm">How can I create early bird fees with Webform CiviCRM?</a></p>
  
  <p><a href="https://civicrm.stackexchange.com/questions/24565/calculated-member-fees">Calculated member fees</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-20T19:48:36.467Z
Answers.LastActivityDate: 2018-04-20T19:59:34.350Z
Answers.LastEditDate: 2018-04-20T19:59:34.350Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>I have a select custom field for 'Accommodation' showing the options available for participants in events' registration form.
  To simplify, lets say there are 10 different accommodation options, 'option 1' until 'option 10'. 
  It gets complicated when each of the different events (around 100 different events) have a different subset of those options, and not all 10 options are available for each event. So event A has options 1,2,3, event B has 2,3,5,7, and event C has all 10 options available.</p>
  
  <p>I created a custom field for each subset of options, but came to a point of having almost 20 different custom fields called accommodation, and then trying to draw up a report of all participants from all events, showing which accommodation option they chose - is just a big mess with 20 custom fields that do not intersect.</p>
  
  <p>My question is how to have only one custom field with all 10 options, but then to somehow specify for each event which out of the 10 options should be displayed and available for choice, for that particular event.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-19T23:09:03.970Z
Comments.Text: afaik in civi itself js is only way to do this. if using Drupal then Webform can probably deliver it too without js
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-20T11:01:50.953Z
Comments.Text: I am using Drupal but am not familiar with how to work with Webform. Can you give me orientation how to do that?
Comments.UserDisplayName: Elad
Tags: <civievent><custom-fields>
Title: Different subsets of a selection custom field
ThreadText: # Different subsets of a selection custom field
  
  (Asked by: username_0 on 2018-04-19)
  
  I have a select custom field for 'Accommodation' showing the options available for participants in events' registration form.
  To simplify, lets say there are 10 different accommodation options, 'option 1' until 'option 10'.
  It gets complicated when each of the different events (around 100 different events) have a different subset of those options, and not all 10 options are available for each event. So event A has options 1,2,3, event B has 2,3,5,7, and event C has all 10 options available.
  
  I created a custom field for each subset of options, but came to a point of having almost 20 different custom fields called accommodation, and then trying to draw up a report of all participants from all events, showing which accommodation option they chose - is just a big mess with 20 custom fields that do not intersect.
  
  My question is how to have only one custom field with all 10 options, but then to somehow specify for each event which out of the 10 options should be displayed and available for choice, for that particular event.
  
  **Tags:** civievent, custom-fields
  
  > **Comments:**
  > **username_1**: afaik in civi itself js is only way to do this. if using Drupal then Webform can probably deliver it too without js  
  > **username_0**: I am using Drupal but am not familiar with how to work with Webform. Can you give me orientation how to do that?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2018-05-07. Score: 0 | Accepted answer
  
  I did it with javascript:
  CRM/Event/Form/Registration/Register.tpl (custom_209 is the custom field attached to the event configuration page, to show which accommodation options should be valid for this event, out of the field 209 which has ALL possibilities) -
  
      {crmAPI var='result' entity='Event' action='getsingle' return='custom_209' id=$event.id}
      {foreach from=$result.custom_209 item=value key=field}{$value},{/foreach}
  
  
  And then in a custom .js file in the registration form itself:
  const ID_HIDDEN_DIV_EVENT_ACCOMMODATION_VALID_OPTIONS = 'event_accommodation'; // This is set in the CRM/Event/Form/Registration/Register.tpl
  
  function hideInvalidAccommodationOptions()
  {
      if (jQuery("input[name='" + CUSTOM_FILED_EVENT_ACCOMMODATION + "']").length == 0)
      {
          // There is not accommodation field in this form. Could be an online course or a different type of seminar.
          return;
      }
  
      var validAccOptionsString = jQuery('#' + ID_HIDDEN_DIV_EVENT_ACCOMMODATION_VALID_OPTIONS).text().trim();
  
      if (validAccOptionsString.length == 0)
      {
          // No accommodation specification were set for this event
          return;
      }
  
      // Remove the last comma (,) from the string
      validAccOptionsString = validAccOptionsString.slice(0,-1);
  
      var validAccOptionsArr = validAccOptionsString.split(',');
      var accOptionsInputElementsArr = jQuery("input[name='" + CUSTOM_FILED_EVENT_ACCOMMODATION + "']");
  
      // Iterate through all possible accommodation input elements
      jQuery.each(accOptionsInputElementsArr, function(i, accOptionInputElement)
      {
          var $accOptionInput = jQuery(accOptionInputElement);
  
          // If the input element's value is not found in the specified event accommodation options
          if (jQuery.inArray($accOptionInput.attr("value"), validAccOptionsArr) == -1)
          {
              // Go up twice in the DOM from the input, to the td, to the tr, and remove the whole tr from the DOM.
              $accOptionInput.parent().parent().remove();
          }
      });
  }
  
  
  ---
  
  ### Answer by username_1 on 2018-04-20. Score: 0
  
  To do this via webform\_civicrm
  
  Download and enable [webform\_civicrm](https://www.drupal.org/project/webform_civicrm) and read the documentation.
  
  Google for some answers on SE or our blog at fuzion.co.nz/blog for some explanations about doing Events via webform\_civicrm eg
  
  <https://www.fuzion.co.nz/blogs/registering-multiple-people-multiple-events>
  
  <https://civicrm.stackexchange.com/questions/tagged/webform-civicrm>
  
  [How can I create early bird fees with Webform CiviCRM?](https://civicrm.stackexchange.com/questions/24578/how-can-i-create-early-bird-fees-with-webform-civicrm)
  
  [Calculated member fees](https://civicrm.stackexchange.com/questions/24565/calculated-member-fees)
  
  
  ---
  
  