Answers.Body: <p>As long as there’s a fee for all options then try this method –</p>
  <p>When editing or creating a price set, enter a value in the ‘Minimum Amount’ field.
  In this example, I’ve entered 5, as that’s the smallest fee available for this event.</p>
  <p><a href="https://i.sstatic.net/ew9ns.png" rel="noreferrer"><img src="https://i.sstatic.net/ew9ns.png" alt="Minimum Amount" /></a></p>
  <p>None of the price fields have ben set to required -</p>
  <p><a href="https://i.sstatic.net/zUddC.png" rel="noreferrer"><img src="https://i.sstatic.net/zUddC.png" alt="Not Required" /></a></p>
  <p>If a participant attempts to select ‘none’ for all of the options, they will be presented with the below message and will not be able to proceed -</p>
  <p><a href="https://i.sstatic.net/qbiYr.png" rel="noreferrer"><img src="https://i.sstatic.net/qbiYr.png" alt="Alert Message" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-17T17:33:24.703Z
Answers.Text: That's an interesting idea just that would allow picking e.g. BOTH adult and youth options, whereas it sounds like they only want them to pick one option out of all.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-17T20:55:45.150Z
Answers.Text: That may work out. As mentioned, someone could potentially choose multiple options, but that's less of an issue.
Answers.UserDisplayName: PoHo
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-17T17:19:00.667Z
Answers.LastActivityDate: 2022-06-17T17:19:00.667Z
Answers.UserDisplayName: Anil
Answers.Body: <p>If you need something more custom, and you are not afraid to do a bit of code, you can always add a validation using hook_civicrm_validateForm (and optionally using javascript).</p>
  <p>For hook_civicrm_validateForm, you need to create an extension with the function that looks like :</p>
  <pre><code>function myextension_civicrm_validateForm($formName, &amp;$fields, &amp;$files, &amp;$form, &amp;$errors) {
  
    if ($formName == 'CRM_Event_Form_Registration_Register') {
  
      $formId = $form-&gt;getVar('_id');
      // event id in this case
      if ($formId == 1) {
  
        // add whatever logic you want
        $price1 = CRM_Utils_Array::value('price_1', $fields);
        $price2 = CRM_Utils_Array::value('price_2', $fields);
        $price3 = CRM_Utils_Array::value('price_3', $fields);
  
        if (empty($price1) &amp;&amp; empty($price2) &amp;&amp; empty($price3)) {
          $errors[&quot;price_1&quot;] = ts('You must choose one price item');
        }
  
      }
  
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-29T17:54:18.230Z
Answers.Text: Thank you. Unfortunately I am not personally confident enough in my coding skills that I'd feel comfortable making this change, but it's good to know that it's possible. This could be helpful to me, and others, in the future though when I feel like I can do that.
Answers.UserDisplayName: PoHo
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-28T13:53:00.117Z
Answers.LastActivityDate: 2022-06-28T13:53:00.117Z
Answers.UserDisplayName: samuelsov
Answers.Body: <p>Can you just put all the options into one field? Are you separating them into multiple fields purely for visual reasons? If so, then maybe you can use some custom css to do that, e.g. <code>div.price-set-row.fieldname-row3 { margin-top: 1em; }</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-17T20:54:02.497Z
Answers.Text: This is not ideal but is my backup plan if there's no other solutions that work for us
Answers.UserDisplayName: PoHo
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-17T16:49:09.737Z
Answers.LastActivityDate: 2022-06-17T16:49:09.737Z
Answers.UserDisplayName: Demerit
Body: <p>I am trying to create a Price Set with multiple fields, each with multiple options, and require one option from any of the fields. Is it possible to make the Price Set itself required, or can you only make individual fields required?</p>
  <p>We have multiple pricing options for Adults, Youth, and Children so each category is its own field. I don't want to make the fields required since a single person isn't an Adult <em>and</em> Youth <em>and</em> Child. However, if I include 'none' options then it is possible for someone to have no selection at all. It appears this question has been asked <a href="https://civicrm.stackexchange.com/questions/33978/allow-only-1-selection-in-a-price-set-with-multiple-price-fields">before</a> but there was no solution back then. I'm hoping there is one now.</p>
  
Tags: <price-sets><payment>
Title: Can I make a price set required?
ThreadText: # Can I make a price set required?
  
  (Asked by: username_0 on 2022-06-17)
  
  I am trying to create a Price Set with multiple fields, each with multiple options, and require one option from any of the fields. Is it possible to make the Price Set itself required, or can you only make individual fields required?
  
  We have multiple pricing options for Adults, Youth, and Children so each category is its own field. I don't want to make the fields required since a single person isn't an Adult *and* Youth *and* Child. However, if I include 'none' options then it is possible for someone to have no selection at all. It appears this question has been asked [before](https://civicrm.stackexchange.com/questions/33978/allow-only-1-selection-in-a-price-set-with-multiple-price-fields) but there was no solution back then. I'm hoping there is one now.
  
  **Tags:** price-sets, payment
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2022-06-17. Score: 5
  
  As long as there’s a fee for all options then try this method –
  
  When editing or creating a price set, enter a value in the ‘Minimum Amount’ field.
  In this example, I’ve entered 5, as that’s the smallest fee available for this event.
  
  [![Minimum Amount](https://i.sstatic.net/ew9ns.png)](https://i.sstatic.net/ew9ns.png)
  
  None of the price fields have ben set to required -
  
  [![Not Required](https://i.sstatic.net/zUddC.png)](https://i.sstatic.net/zUddC.png)
  
  If a participant attempts to select ‘none’ for all of the options, they will be presented with the below message and will not be able to proceed -
  
  [![Alert Message](https://i.sstatic.net/qbiYr.png)](https://i.sstatic.net/qbiYr.png)
  
  > **Comments:**
  > **username_2**: That's an interesting idea just that would allow picking e.g. BOTH adult and youth options, whereas it sounds like they only want them to pick one option out of all.  
  > **username_0**: That may work out. As mentioned, someone could potentially choose multiple options, but that's less of an issue.  
  
  ---
  
  ### Answer by username_3 on 2022-06-28. Score: 2
  
  If you need something more custom, and you are not afraid to do a bit of code, you can always add a validation using hook\_civicrm\_validateForm (and optionally using javascript).
  
  For hook\_civicrm\_validateForm, you need to create an extension with the function that looks like :
  
  ```
  function myextension_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
  
    if ($formName == 'CRM_Event_Form_Registration_Register') {
  
      $formId = $form->getVar('_id');
      // event id in this case
      if ($formId == 1) {
  
        // add whatever logic you want
        $price1 = CRM_Utils_Array::value('price_1', $fields);
        $price2 = CRM_Utils_Array::value('price_2', $fields);
        $price3 = CRM_Utils_Array::value('price_3', $fields);
  
        if (empty($price1) && empty($price2) && empty($price3)) {
          $errors["price_1"] = ts('You must choose one price item');
        }
  
      }
  
    }
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you. Unfortunately I am not personally confident enough in my coding skills that I'd feel comfortable making this change, but it's good to know that it's possible. This could be helpful to me, and others, in the future though when I feel like I can do that.  
  
  ---
  
  ### Answer by username_2 on 2022-06-17. Score: 2
  
  Can you just put all the options into one field? Are you separating them into multiple fields purely for visual reasons? If so, then maybe you can use some custom css to do that, e.g. `div.price-set-row.fieldname-row3 { margin-top: 1em; }`
  
  > **Comments:**
  > **username_0**: This is not ideal but is my backup plan if there's no other solutions that work for us  
  
  ---
  
  