The recurring contribution "edit" form shows the following fields:
and when trying to submit the form it shows the following message:
After
These fields are now hidden:
Frequency
Instalments
Cycle Day
Next Scheduled instalment
and when trying to submit the form, it no longer mentions the "Cycle day", but rather it shows the same message that appear to "annual" payment plans:
where recurring contributions that are not linked to a payment scheme still work as they used to where all these fields are visible:
Technical Details
The "Cycle day" and "Next Scheduled Contribution Date" do not exist on the original CiviCRM recurring contribution form, and they were rather added by us inside the buildForm hook, so hiding both of them was a matter of adding an if condition so they are only added if the edited recurring contribution is linked to a payment scheme.
But because we also have some validations inside the form validation hook related to these two fields and some other stuff we do in the postProcess hook, I also had to also to update these two hooks to ignore these operations in case of payment schemes.
For the "instalments" and the "frequency" fields, and given they are added to the form by CiviCRM core, I had to use Javascript/JQuery to hide them.
Overview
In this PR: https://github.com/compucorp/uk.co.compucorp.membershipextras/pull/473 we hid several fields from the recurring contribution view page if it is linked to a payment scheme, here we are doing the same on the recurring contribution edit form.
Before
The recurring contribution "edit" form shows the following fields:
and when trying to submit the form it shows the following message:
After
These fields are now hidden:
and when trying to submit the form, it no longer mentions the "Cycle day", but rather it shows the same message that appear to "annual" payment plans:
where recurring contributions that are not linked to a payment scheme still work as they used to where all these fields are visible:
Technical Details
The "Cycle day" and "Next Scheduled Contribution Date" do not exist on the original CiviCRM recurring contribution form, and they were rather added by us inside the buildForm hook, so hiding both of them was a matter of adding an if condition so they are only added if the edited recurring contribution is linked to a payment scheme.
But because we also have some validations inside the form validation hook related to these two fields and some other stuff we do in the postProcess hook, I also had to also to update these two hooks to ignore these operations in case of payment schemes.
For the "instalments" and the "frequency" fields, and given they are added to the form by CiviCRM core, I had to use Javascript/JQuery to hide them.