-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
dev/core#4144 Fix smarty notice on isDuplicate #25657
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,11 +61,6 @@ class CRM_Profile_Form extends CRM_Core_Form { | |
*/ | ||
public $_grid; | ||
|
||
/** | ||
* Name of button for saving matching contacts. | ||
* @var string | ||
*/ | ||
protected $_duplicateButtonName; | ||
/** | ||
* The title of the category we are editing. | ||
* | ||
|
@@ -206,7 +201,7 @@ protected static function handleDuplicateChecking(&$errors, $fields, $form) { | |
$form->_id = $ids[0]; | ||
} | ||
else { | ||
if ($form->_context == 'dialog') { | ||
if ($form->isEntityReferenceContactCreateMode()) { | ||
$contactLinks = CRM_Contact_BAO_Contact_Utils::formatContactIDSToLinks($ids, TRUE, TRUE); | ||
|
||
$duplicateContactsLinks = '<div class="matching-contacts-found">'; | ||
|
@@ -249,9 +244,10 @@ protected static function handleDuplicateChecking(&$errors, $fields, $form) { | |
|
||
$errors['_qf_default'] = $duplicateContactsLinks; | ||
|
||
// let smarty know that there are duplicates | ||
$template = CRM_Core_Smarty::singleton(); | ||
$template->assign('isDuplicate', 1); | ||
// The button 'Save Matching Contact' is added in buildForm | ||
// but we only decide here whether ot not to show it - ie | ||
// if validation failed due to there being duplicates. | ||
CRM_Core_Smarty::singleton()->assign('showSaveDuplicateButton', 1); | ||
} | ||
else { | ||
$errors['_qf_default'] = ts('A record already exists with the same information.'); | ||
|
@@ -261,6 +257,18 @@ protected static function handleDuplicateChecking(&$errors, $fields, $form) { | |
return $errors; | ||
} | ||
|
||
/** | ||
* Is this being called from an entity reference field. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. helpful explanation |
||
* | ||
* E.g clicking on 'New Organization' from the employer field | ||
* would create a link with the context = 'dialog' in the url. | ||
* | ||
* @return bool | ||
*/ | ||
public function isEntityReferenceContactCreateMode(): bool { | ||
return $this->_context === 'dialog'; | ||
} | ||
|
||
/** | ||
* Explicitly declare the entity api name. | ||
*/ | ||
|
@@ -329,7 +337,6 @@ public function preProcess() { | |
CRM_Core_Error::statusBounce(ts('Proper action not specified for this custom value record profile')); | ||
} | ||
} | ||
$this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate'); | ||
|
||
$gids = explode(',', (CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0) ?? '')); | ||
|
||
|
@@ -897,10 +904,14 @@ public function buildQuickForm(): void { | |
$this->freeze(); | ||
} | ||
|
||
if ($this->_context == 'dialog') { | ||
// Assign FALSE, here - this is overwritten during form validation | ||
// if duplicates are found during submit. | ||
CRM_Core_Smarty::singleton()->assign('showSaveDuplicateButton', FALSE); | ||
|
||
if ($this->isEntityReferenceContactCreateMode()) { | ||
$this->addElement( | ||
'xbutton', | ||
$this->_duplicateButtonName, | ||
$this->getButtonName('upload', 'duplicate'), | ||
ts('Save Matching Contact'), | ||
[ | ||
'type' => 'submit', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ | |
<div id="crm-container" class="crm-container crm-public" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}"> | ||
{/if} | ||
|
||
{if $isDuplicate and ( ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192) ) } | ||
{if $showSaveDuplicateButton} | ||
<div class="crm-submit-buttons"> | ||
{$form._qf_Edit_upload_duplicate.html} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems odd that we hard-code the button name here, and go to the trouble to generate it dynamically in Form.php... but if it works, fine |
||
</div> | ||
|
@@ -50,7 +50,7 @@ | |
{if $action eq 2 and $multiRecordFieldListing} | ||
<h1>{ts}Edit Details{/ts}</h1> | ||
<div class="crm-submit-buttons" style='float:right'> | ||
{include file="CRM/common/formButtons.tpl" location=''}{if $isDuplicate}{$form._qf_Edit_upload_duplicate.html}{/if} | ||
{include file="CRM/common/formButtons.tpl" location=''}{if $showSaveDuplicateButton}{$form._qf_Edit_upload_duplicate.html}{/if} | ||
</div> | ||
{/if} | ||
|
||
|
@@ -94,7 +94,7 @@ | |
<div class="content description">{$field.help_pre}</div> | ||
</div> | ||
{/if} | ||
{if $field.options_per_line} | ||
{if array_key_exists('options_per_line', $field) && $field.options_per_line} | ||
<div class="crm-section editrow_{$n}-section form-item" id="editrow-{$n}"> | ||
<div class="label">{$form.$n.label}</div> | ||
<div class="content edit-value"> | ||
|
@@ -201,7 +201,7 @@ | |
</div> | ||
{/if} | ||
<div class="crm-submit-buttons" style='{$floatStyle}'> | ||
{include file="CRM/common/formButtons.tpl" location=''}{if $isDuplicate}{$form._qf_Edit_upload_duplicate.html}{/if} | ||
{include file="CRM/common/formButtons.tpl" location=''}{if $showSaveDuplicateButton}{$form._qf_Edit_upload_duplicate.html}{/if} | ||
{if $includeCancelButton} | ||
<a class="button cancel" href="{$cancelURL}"> | ||
<span> | ||
|
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.
this just muddies the waters using a property
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.
I agree, strange choice