Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/src/Controller/Component/BreadcrumbComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ public function injectPrimaryLink(
$linkTable = \Cake\ORM\TableRegistry::getTableLocator()->get($linkModelFqn);
$contain = $this->resolveContainList($linkTable, $mappedAction);

// Normalize attr (people_id → id when the attr matches the model’s own foreign key)
// Use the table alias for query building (avoid plugin-qualified names in SQL)
$modelAlias = $linkTable->getAlias();
$foreignKey = StringUtilities::classNameToForeignKey($modelAlias);
$linkAttr = ($link->attr === $foreignKey) ? 'id' : $link->attr;

$linkAttr = (string)$linkTable->getPrimaryKey();

// Fetch the linked entity; if not found, handle gracefully
$linkedEntity = $linkTable
Expand Down
10 changes: 9 additions & 1 deletion app/src/Controller/PeopleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,15 @@ public function confirmDelete(string $id) {
'PetitionHistoryRecords'
];

$this->set('vv_person', $this->People->get((int)$id, contain: $contain));
$person = $this->People->get((int)$id, contain: $contain);
$this->set('vv_person', $person);

$this->Breadcrumb->injectTitleLink(
table: $this->People,
entity: $person,
action: 'edit',
label: $this->People->generateDisplayField($person)
);

$this->set('vv_title', __d('operation', 'delete.confirm.title'));

Expand Down
2 changes: 1 addition & 1 deletion app/templates/People/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if($vv_action == 'add') {
// The initial name must be primary
'names.0.primary_name' => true
];
} elseif($vv_action == 'edit') {
} else {
$a = $vv_obj->extract(['person_role_id', 'person_id']);

$useDeleteSplashPage = true;
Expand Down
18 changes: 16 additions & 2 deletions app/templates/Standard/add-edit-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,22 @@
$perm = $vv_permissions[$linkModel][$t['link']['action']];
}

// Inject a link to the current object ID
$t['link']['?'][\App\Lib\Util\StringUtilities::entityToForeignKey($vv_obj)] = $vv_obj->id;
// This fixes the link in the gear icon in the Person Canvas view.
// Inject a link to the current object ID, unless an equivalent specific foreign key
// (like subject_person_id) is already provided in the query arguments.
$fk = \App\Lib\Util\StringUtilities::entityToForeignKey($vv_obj);
$hasFk = false;
if(!empty($t['link']['?'])) {
foreach($t['link']['?'] as $k => $v) {
if($v === $vv_obj->id && (str_ends_with($k, '_' . $fk) || $k === $fk)) {
$hasFk = true;
break;
}
}
}
if(!$hasFk) {
$t['link']['?'][$fk] = $vv_obj->id;
}
} else {
$perm = $vv_permissions[$t['link']['action']];

Expand Down