Body: <p>I'm seeing this error when saving changes to a contribution page in 5.14.0, Drupal 7:</p>
  
  <p>"DB Constraint Violation - price_field_id should possibly be marked as mandatory for PriceFieldValue,get API. If so, please raise a bug report"</p>
  
  <p>Debug / trace info:</p>
  
  <p>CiviCRM_API3_Exception: "DB Constraint Violation - price_field_id should possibly be marked as mandatory for PriceFieldValue,get API. If so, please raise a bug report."</p>
  
  <pre><code>#0 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Price/BAO/PriceField.php(189): civicrm_api3("price_field_value", "get", (Array:2))
  #1 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Member/Form/MembershipBlock.php(443): CRM_Price_BAO_PriceField::create((Array:14))
  #2 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/Form.php(490): CRM_Member_Form_MembershipBlock-&gt;postProcess()
  #3 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(169): CRM_Core_Form-&gt;mainProcess()
  #4 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(136): CRM_Core_QuickForm_Action_Upload-&gt;realPerform(Object(CRM_Member_Form_MembershipBlock), "upload")
  #5 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload-&gt;perform(Object(CRM_Member_Form_MembershipBlock), "upload")
  #6 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller-&gt;handle(Object(CRM_Member_Form_MembershipBlock), "upload")
  #7 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/Controller.php(349): HTML_QuickForm_Page-&gt;handle("upload")
  #8 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(114): CRM_Core_Controller-&gt;run()
  #9 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/Invoke.php(284): CRM_Utils_Wrapper-&gt;run("CRM_Member_Form_MembershipBlock", "Membership Section", (Array:0))
  #10 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/Invoke.php(85): CRM_Core_Invoke::runItem((Array:13))
  #11 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
  #12 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/drupal/civicrm.module(444): CRM_Core_Invoke::invoke((Array:4))
  #13 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/includes/menu.inc(527): civicrm_invoke("admin", "contribute", "membership")
  #14 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/index.php(21): menu_execute_active_handler()
  #15 {main}
  </code></pre>
  
  <p>Specifically, it's happening when trying to change the "auto-renew" to "optional", although it has occasionally popped up before.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-03T19:36:36.143Z
Comments.Text: Can you resave the contribution page with membership type and they purchasing membership online?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-03T20:58:10.107Z
Comments.Text: Not sure I totally get what you are asking. I tried creating a copy of the page and had the same error. I can save other changes to the contribution page (description, etc.)
Comments.UserDisplayName: Brian Payst
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-03T21:15:14.057Z
Comments.Text: Can you resave the membership type you trying to use in contribution page? Go to Membership type >> Edit membership type and save
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-04T15:43:04.780Z
Comments.Text: I resaved all of them, still get the same error. I created a new contribution page and it worked the first time after I finished configuring it, but when I went back to edit it I got the same error again.
Comments.UserDisplayName: Brian Payst
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-04T15:52:16.413Z
Comments.Text: Yes, Its a problem with how price set options are stored for that contribution page.
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-04T16:13:14.753Z
Comments.Text: I'm not using price sets on that contribution page, it's just membership options set up through Administer -> CiviMember->Membership Types
Comments.UserDisplayName: Brian Payst
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-04T16:22:50.033Z
Comments.Text: Removing the memberships from the contribution page and then adding them again appeared to have fixed it, then when I checked "require membership sign up" it gave me the error again.
Comments.UserDisplayName: Brian Payst
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-04T16:29:06.060Z
Comments.Text: I was able work around the issue but removing the memberships, adding them back, checking the required box and saving. Still would be good to have any ideas about the underlying problem.
Comments.UserDisplayName: Brian Payst
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-04T17:02:31.623Z
Comments.Text: Even though you are not using price set the form creates hidden price set (aka quick config price set). It might have been possible the options you had selected previously wasn't saved in db or got deleted from db hence it was throwing errors.
Comments.UserDisplayName: Pradeep Nayak
Tags: <civicontribute>
Title: Contribution Page Error: price_field_id should possibly be marked as mandatory
ThreadText: # Contribution Page Error: price_field_id should possibly be marked as mandatory
  
  (Asked by: username_0 on 2019-07-03)
  
  I'm seeing this error when saving changes to a contribution page in 5.14.0, Drupal 7:
  
  "DB Constraint Violation - price\_field\_id should possibly be marked as mandatory for PriceFieldValue,get API. If so, please raise a bug report"
  
  Debug / trace info:
  
  CiviCRM\_API3\_Exception: "DB Constraint Violation - price\_field\_id should possibly be marked as mandatory for PriceFieldValue,get API. If so, please raise a bug report."
  
  ```
  #0 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Price/BAO/PriceField.php(189): civicrm_api3("price_field_value", "get", (Array:2))
  #1 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Member/Form/MembershipBlock.php(443): CRM_Price_BAO_PriceField::create((Array:14))
  #2 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/Form.php(490): CRM_Member_Form_MembershipBlock->postProcess()
  #3 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(169): CRM_Core_Form->mainProcess()
  #4 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php(136): CRM_Core_QuickForm_Action_Upload->realPerform(Object(CRM_Member_Form_MembershipBlock), "upload")
  #5 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Upload->perform(Object(CRM_Member_Form_MembershipBlock), "upload")
  #6 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Member_Form_MembershipBlock), "upload")
  #7 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/Controller.php(349): HTML_QuickForm_Page->handle("upload")
  #8 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(114): CRM_Core_Controller->run()
  #9 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/Invoke.php(284): CRM_Utils_Wrapper->run("CRM_Member_Form_MembershipBlock", "Membership Section", (Array:0))
  #10 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/Invoke.php(85): CRM_Core_Invoke::runItem((Array:13))
  #11 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
  #12 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/sites/all/modules/civicrm/drupal/civicrm.module(444): CRM_Core_Invoke::invoke((Array:4))
  #13 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/includes/menu.inc(527): civicrm_invoke("admin", "contribute", "membership")
  #14 /srv/bindings/6c14623afcd2452794b02998ab5fa02a/code/index.php(21): menu_execute_active_handler()
  #15 {main}
  
  ```
  
  Specifically, it's happening when trying to change the "auto-renew" to "optional", although it has occasionally popped up before.
  
  **Tags:** civicontribute
  
  > **Comments:**
  > **username_1**: Can you resave the contribution page with membership type and they purchasing membership online?  
  > **username_0**: Not sure I totally get what you are asking. I tried creating a copy of the page and had the same error. I can save other changes to the contribution page (description, etc.)  
  > **username_1**: Can you resave the membership type you trying to use in contribution page? Go to Membership type >> Edit membership type and save  
  > **username_0**: I resaved all of them, still get the same error. I created a new contribution page and it worked the first time after I finished configuring it, but when I went back to edit it I got the same error again.  
  > **username_1**: Yes, Its a problem with how price set options are stored for that contribution page.  
  > **username_0**: I'm not using price sets on that contribution page, it's just membership options set up through Administer -> CiviMember->Membership Types  
  > **username_0**: Removing the memberships from the contribution page and then adding them again appeared to have fixed it, then when I checked "require membership sign up" it gave me the error again.  
  > **username_0**: I was able work around the issue but removing the memberships, adding them back, checking the required box and saving. Still would be good to have any ideas about the underlying problem.  
  > **username_1**: Even though you are not using price set the form creates hidden price set (aka quick config price set). It might have been possible the options you had selected previously wasn't saved in db or got deleted from db hence it was throwing errors.  
  
  ---
  
  ## 0 answers
  
  