Skip to content

Commit

Permalink
SearchKit - Fix editable when displaying an icon
Browse files Browse the repository at this point in the history
Fixes a regression caused by civicrm#23404
  • Loading branch information
colemanw authored and eileenmcnaughton committed Aug 23, 2022
1 parent 71f0493 commit 5abc45a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Civi/Api4/Generic/DAOGetFieldsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ private function getFkFieldSpec($fieldName, $fields) {
private function formatValues() {
foreach (array_keys($this->values) as $key) {
if (strpos($key, ':')) {
[$fieldName, $suffix] = explode(':', $key);
$context = FormattingUtil::$pseudoConstantContexts[$suffix] ?? NULL;
if (!$context) {
throw new \API_Exception('Illegal expression');
if (isset($this->values[$key]) && $this->values[$key] !== '') {
[$fieldName, $suffix] = explode(':', $key);
$context = FormattingUtil::$pseudoConstantContexts[$suffix] ?? NULL;
// This only works for basic pseudoconstants like :name :label and :abbr. Skip others.
if ($context) {
$baoName = CoreUtil::getBAOFromApiName($this->getEntityName());
$options = $baoName::buildOptions($fieldName, $context) ?: [];
$this->values[$fieldName] = FormattingUtil::replacePseudoconstant($options, $this->values[$key], TRUE);
}
}
$baoName = CoreUtil::getBAOFromApiName($this->getEntityName());
$options = $baoName::buildOptions($fieldName, $context) ?: [];
$this->values[$fieldName] = FormattingUtil::replacePseudoconstant($options, $this->values[$key], TRUE);
unset($this->values[$key]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ public function testInPlaceEditAndCreate() {
'label' => 'Name',
'type' => 'field',
'editable' => TRUE,
'icons' => [['field' => 'activity_type_id:icon', 'side' => 'left']],
],
[
'key' => 'Contact_Email_contact_id_01.email',
Expand Down

0 comments on commit 5abc45a

Please sign in to comment.