1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 16:26:59 +02:00
This commit is contained in:
Ryan Cramer
2023-09-07 10:29:44 -04:00
parent 6df11e5e46
commit 5b76d4e340

View File

@@ -1754,6 +1754,29 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
return $pagefiles;
}
/**
* Called after field renamed
*
* @param Field $field
* @param string $prevName Previous name (current name can be found in $field->name)
*
*/
public function ___renamedField(Field $field, $prevName) {
// if there is a custom-fields template, rename it
$templates = $this->wire()->templates;
if($templates->get("field-$field->name")) return;
if($templates->get("field-x-$field->name")) return;
$template = $templates->get("field-$prevName");
if($template) {
$templates->rename($template, "field-$field->name");
} else {
$template = $templates->get("field-x-$prevName");
if($template) {
$templates->rename($template, "field-x-$field->name");
}
}
}
/**
* Field config
*