Answers.Body: <p>Here's what I ended up doing. It feels a bit weird, but so far it seems to do the trick.</p>
  <p>Having created the fields I need for the two contacts, and ensuring that buyer is contact 1 (because the contribution appears to only work for contact 1), I can then specify a membership that will be applied to contact 2.</p>
  <p>Even though I've set a minimum price for the membership in CiviCRM, the form seems to take no notice of this. So in order to have a price appear on the form, in the Civi settings tab for the form I enable a contribution. This still doesn't let me set a price anywhere, so in the form component for Contribution Amount I set a default value - the price I want to set, and I configure the form component so that it is read-only (otherwise the user could edit the price).</p>
  <p>The form now looks sensible, a payment gets processed for the right amount, and a membership gets created.</p>
  <p>What I need to try to work out now if how I can provide a choice of price options?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-14T19:57:01.160Z
Answers.Text: Yes, this seems right, I'm not sure what parts are feeling weird. An important thing about webform civicrm is that it doesn't have the same kinds of built-in hard-coded "business rules" that the civicrm forms have. That's good and bad, but for flexibility and defining those rules yourself, it's definitely good. To answer your last question, I think you would convert the price field to a list box.
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-21T16:33:44.477Z
Answers.LastActivityDate: 2021-09-21T16:33:44.477Z
Answers.UserDisplayName: Graham
Body: <p>I want to set up a Drupal 9 webform to enable people to buy a gift membership. I don't want to use the Gift Membership extension because it's approach of creating a redeemable code doesn't fit with our business processes: we want to be able to contact the recipient of the gift membership directly as part of the on-boarding process, and create a relationship between the purchaser and the holder of the membership.</p>
  <p>So I need the webform to create the two contact records in CiviCRM so that I can then communicate appropriately to both the purchaser and the member.</p>
  <p>My work so far on this seems to indicate that this isn't achievable, but I may well be missing a trick. Webform_CiviCRM appears to assume that any contribution is linked to Contact 1 in the form (there's no option to choose the contact that will be linked to the contribution record). If I then specify that I want a membership for Contact 2, the price for the membership doesn't appear to get included, so the total is always 0, and no payment can be processed.</p>
  <p>Can I use the 'in honour of' element? (never used it before so I'm unclear as to what it actually does).</p>
  <p>Has anyone got anything like this working? Am I doing something wrong?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-09T09:54:17.700Z
Comments.Text: does this provide any hints? https://civicrm.stackexchange.com/questions/6306/webform-civicrm-and-gift-membership
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-09T10:07:10.270Z
Comments.Text: Thanks - already seen that. It appears to relate to D7, and the link to instructions is broken as it's pointing to the old wiki.
Comments.UserDisplayName: Graham
Tags: <drupal><civimember><webform-civicrm><contributions><gift-memberships>
Title: How can I create a D9 webform where contact 1 pays for a membership that applies to contact 2?
ThreadText: # How can I create a D9 webform where contact 1 pays for a membership that applies to contact 2?
  
  (Asked by: username_0 on 2021-09-09)
  
  I want to set up a Drupal 9 webform to enable people to buy a gift membership. I don't want to use the Gift Membership extension because it's approach of creating a redeemable code doesn't fit with our business processes: we want to be able to contact the recipient of the gift membership directly as part of the on-boarding process, and create a relationship between the purchaser and the holder of the membership.
  
  So I need the webform to create the two contact records in CiviCRM so that I can then communicate appropriately to both the purchaser and the member.
  
  My work so far on this seems to indicate that this isn't achievable, but I may well be missing a trick. Webform\_CiviCRM appears to assume that any contribution is linked to Contact 1 in the form (there's no option to choose the contact that will be linked to the contribution record). If I then specify that I want a membership for Contact 2, the price for the membership doesn't appear to get included, so the total is always 0, and no payment can be processed.
  
  Can I use the 'in honour of' element? (never used it before so I'm unclear as to what it actually does).
  
  Has anyone got anything like this working? Am I doing something wrong?
  
  **Tags:** drupal, civimember, webform-civicrm, contributions, gift-memberships
  
  > **Comments:**
  > **username_1**: does this provide any hints? https://civicrm.stackexchange.com/questions/6306/webform-civicrm-and-gift-membership  
  > **username_0**: Thanks - already seen that. It appears to relate to D7, and the link to instructions is broken as it's pointing to the old wiki.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-09-21. Score: 0 | Accepted answer
  
  Here's what I ended up doing. It feels a bit weird, but so far it seems to do the trick.
  
  Having created the fields I need for the two contacts, and ensuring that buyer is contact 1 (because the contribution appears to only work for contact 1), I can then specify a membership that will be applied to contact 2.
  
  Even though I've set a minimum price for the membership in CiviCRM, the form seems to take no notice of this. So in order to have a price appear on the form, in the Civi settings tab for the form I enable a contribution. This still doesn't let me set a price anywhere, so in the form component for Contribution Amount I set a default value - the price I want to set, and I configure the form component so that it is read-only (otherwise the user could edit the price).
  
  The form now looks sensible, a payment gets processed for the right amount, and a membership gets created.
  
  What I need to try to work out now if how I can provide a choice of price options?
  
  > **Comments:**
  > **username_2**: Yes, this seems right, I'm not sure what parts are feeling weird. An important thing about webform civicrm is that it doesn't have the same kinds of built-in hard-coded "business rules" that the civicrm forms have. That's good and bad, but for flexibility and defining those rules yourself, it's definitely good. To answer your last question, I think you would convert the price field to a list box.  
  
  ---
  
  