diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index bdc9c861101e..51df03851910 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -337,6 +337,11 @@ public function setDefaultValues() { } } } + else { + if ($this->_contactID) { + $defaults['contact_id'] = $this->_contactID; + } + } //set Soft Credit Type to Gift by default $scTypes = CRM_Core_OptionGroup::values("soft_credit_type"); @@ -493,11 +498,9 @@ public function buildQuickForm() { return; } - if ($this->_context == 'standalone') { - $this->addEntityRef('contact_id', ts('Contact'), [ - 'create' => TRUE, - 'api' => ['extra' => ['email']], - ], TRUE); + $contactField = $this->addEntityRef('contact_id', ts('Contact'), ['create' => TRUE, 'api' => ['extra' => ['email']]], TRUE); + if ($this->_context != 'standalone') { + $contactField->freeze(); } $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -'); diff --git a/templates/CRM/Member/Form/Membership.tpl b/templates/CRM/Member/Form/Membership.tpl index c8d2cd54394d..d16dbfa40665 100644 --- a/templates/CRM/Member/Form/Membership.tpl +++ b/templates/CRM/Member/Form/Membership.tpl @@ -83,14 +83,10 @@ {else} - {if $context neq 'standalone'} - - - - {else} - - - {/if} + + + +
{ts}Member{/ts}{$displayName}
{$form.contact_id.label}{$form.contact_id.html}
{$form.contact_id.label}{$form.contact_id.html}
{$form.membership_type_id.label} {$form.membership_type_id.html}