dev/core#715 - Fix delete action on RelationshipType form #13581
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.
Overview
See https://lab.civicrm.org/dev/core/issues/715
Before
Fatal error when deleting a relationship type
After
Form works
Technical Details
This fixes the bug for now but I'm not sure this is really the right fix long-term.
When I dig into the code of CRM_Core_Form_EntityFormTrait I see that every form has to declare a rather cumbersome array in
setEntityFields
which appears to duplicate metadata that could be retrieved from the api... and then another functionsetEntityFieldsMetadata
which appears to supply that same information that was hard-coded in the previous function.Couldn't all this be avoided by calling
getfields
on the entity and passing in the action? Then we'd avoid trying to retrieve inappropriate fields for that action (which was the cause of this bug) and we'd also avoid all the hard-coded (and hard-to-maintain) getfields boilerplate in thesetEntityFields
fn.