-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set profile greeting fields based on actual contact type #14845
Conversation
(Standard links)
|
So are we confident the form id would always be the contact id here? |
Works in my test, the same scenario that prompted filing the issue. |
@eileenmcnaughton err, no I'm not confident of that. In fact, I notice that there is a |
Ok I've checked some more. This function is really screwy. We can't use the |
) { | ||
$profileType = 'Individual'; | ||
if (!$profileType || in_array($profileType, ['Contact', 'Contribution', 'Participant', 'Membership'])) { | ||
$profileType = ($profileType == 'Contact' && $form->get('id')) ? CRM_Contact_BAO_Contact::getContactType($form->get('id')) : 'Individual'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - I feel like I would probably extract the 'inids' of this function (below the part where $name is determined) and create a sub-function called buildNamedProfile & we could probably restore sanity here.
I did find some reasons to give me enough comfort to merge this though
- Later in the external_identifier part I see a clear assumption that $form->get('id') would be the contact ID
$form->add('text', $name, $title, $attributes, $required);
$contID = $contactId;
if (!$contID) {
$contID = $form->get('id');
}
$form->addRule($name,
ts('External ID already exists in Database.'),
'objectExists',
array('CRM_Contact_DAO_Contact', $contID, 'external_identifier')
);
}
-
On reflection this parameter is ONLY used for the greeting types so the risk is fairly contained.
-
this needs cleaning up but step one is probably just to reformat the file otherwise it's gonna be a pain
This feels like a VERY small step on our general expectation that we should do some cleanup when touching toxic functions - #14853 but it does remove something that was blocking more cleanup |
Overview
Fixes civicrm/org.civicrm.contactlayout#58
Sets greeting options in a profile based on the actual contact type being edited, if applicable.
Before
Contact type was determined based on the profile type, even when editing an existing contact.
After
When editing an existing contact, contact type is determined from that contact.