1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 18:24:57 +02:00
This commit is contained in:
Ryan Cramer
2022-12-30 11:47:45 -05:00
parent f57a07e15a
commit 77c7e401da

View File

@@ -1397,14 +1397,32 @@ class InputfieldFile extends Inputfield implements InputfieldItemList, Inputfiel
}
$context = '';
$process = $this->wire()->process;
if($item && $process instanceof WirePageEditor) {
$contextPage = $process->getPage();
if(wireInstanceOf($contextPage, 'RepeaterPage')) {
$context = "repeater{$contextPage->id}_";
if($item) {
$hasPage = $this->hasPage;
if($hasPage && wireInstanceOf($hasPage, 'RepeaterPage')) {
if(strpos($this->name, '_repeater') === false) {
// ensures that custom fields are properly namespaced within repeater
// though note that this prevents it from working when editing a repeater
// page directly, independently of its forPage
$context = "repeater{$hasPage->id}_";
}
}
/*
* The following does not work with nested repeaters, fixed by the above, but kept here for reference
$process = $this->wire()->process;
if($item && $process instanceof WirePageEditor) {
$contextPage = $process->getPage();
if(wireInstanceOf($contextPage, 'RepeaterPage') && strpos($this->name, '_repeater') === false) {
// @var RepeaterPage $contextPage
$forPage = $contextPage->getForPage();
if($forPage->id) $contextPage = $forPage;
$context = "repeater{$contextPage->id}_";
}
}
*/
}
/** @var Page $page */
$page = $pagefiles->getFieldsPage();
$id = $item ? ('_' . $this->pagefileId($item, $context)) : '';