CIWEMB-492: Prevent switching to the same membership type #519
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before
When trying to switch a membership from one type to another, the current membership type still appears in the list of membership types that you can switch to:
before1.mp4
After
The current membership type no longer appears in the list of membership types that you can switch to:
after1.mp4
Technical details
The "New membership type" field is an a civicrm entity reference field which is added by calling
$this->addEntityRef()
in the buildForm method (see: https://docs.civicrm.org/dev/en/latest/framework/quickform/entityref/) , so all I need is to add an API parameter to$this->addEntityRef()
to exclude the current membership type, also added another parameter to only search for active membership types.About failing tests
The failing test is non relevant to this PR and is already fixed inside this branch: https://github.com/compucorp/uk.co.compucorp.membershipextras/tree/ESEB-53-workstream
which will be part of Membershipextras version 6.1.0