mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 07:47:00 +02:00
Add PR #160 - enable file metadata in repeater context
This commit is contained in:
committed by
Ryan Cramer
parent
4d5950f5fe
commit
7ac6b6e9e3
@@ -304,11 +304,12 @@ class InputfieldFile extends Inputfield implements InputfieldItemList, Inputfiel
|
|||||||
* Get the unique 'id' attribute for the given Pagefile
|
* Get the unique 'id' attribute for the given Pagefile
|
||||||
*
|
*
|
||||||
* @param Pagefile $pagefile
|
* @param Pagefile $pagefile
|
||||||
|
* @param string $context Optional context string (like for repeaters) 3.0.178+
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function pagefileId(Pagefile $pagefile) {
|
protected function pagefileId(Pagefile $pagefile, $context = '') {
|
||||||
return $this->name . "_" . $pagefile->hash;
|
return $this->name . "_" . $context . $pagefile->hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1327,10 +1328,19 @@ class InputfieldFile extends Inputfield implements InputfieldItemList, Inputfiel
|
|||||||
$this->itemFieldgroup = $template->fieldgroup;
|
$this->itemFieldgroup = $template->fieldgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($item) {
|
||||||
|
$page = $pagefiles->getPage();
|
||||||
|
if($page && method_exists($page, 'getForPage') && wireInstanceOf($page, 'RepeaterPage')) {
|
||||||
|
$id = '_' . $this->pagefileId($item, "repeater{$page->id}_");
|
||||||
|
} else {
|
||||||
|
$id = '_' . $this->pagefileId($item);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$id = '';
|
||||||
|
}
|
||||||
|
|
||||||
/** @var Page $page */
|
/** @var Page $page */
|
||||||
$page = $pagefiles->getFieldsPage();
|
$page = $pagefiles->getFieldsPage();
|
||||||
$id = $item ? ('_' . $this->pagefileId($item)) : '';
|
|
||||||
|
|
||||||
$inputfields = $this->itemFieldgroup->getPageInputfields($page, $id, '', false);
|
$inputfields = $this->itemFieldgroup->getPageInputfields($page, $id, '', false);
|
||||||
if(!$inputfields) return false;
|
if(!$inputfields) return false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user