function group_membership_restore_roles_eb in Group 7
Entity builder: Restore original roles to the GroupMembership.
Because entity_form_submit_build_entity() sets all non-field values as entity properties, GroupMembership::changeRoles() may get confused. To rectify this, we reset the roles to the original values.
See also
group_membership_form_submit()
entity_form_submit_build_entity()
1 string reference to 'group_membership_restore_roles_eb'
- group_membership_form in forms/
group_membership.inc - Generates the group membership editing form.
File
- forms/
group_membership.inc, line 88 - Group membership editing UI.
Code
function group_membership_restore_roles_eb($entity_type, $entity, $form, $form_state) {
if ($entity_type == 'group_membership' && !empty($entity->mid)) {
$original = entity_load_unchanged($entity_type, $entity->mid);
$entity->roles = $original->roles;
}
}