1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 17:54:44 +02:00

Add a new Fieldtype::savedField interface method so that Fieldtypes can monitor when a field of their type has been saved, without having to attach a hook

This commit is contained in:
Ryan Cramer
2021-01-22 14:12:58 -05:00
parent e28d2e67e7
commit 0bddf640db
2 changed files with 16 additions and 0 deletions

View File

@@ -300,6 +300,8 @@ class Fields extends WireSaveableItems {
}
}
if($item->type) $item->type->savedField($item);
$this->getTags('reset');
return true;

View File

@@ -46,6 +46,7 @@
* @method bool deleteTemplateField(Template $template, Field $field)
* @method Field cloneField(Field $field)
* @method void renamedField(Field $field, $prevName)
* @method void savedField(Field $field)
* @method void install()
* @method void uninstall()
*
@@ -1474,6 +1475,19 @@ abstract class Fieldtype extends WireData implements Module {
if($field && $prevName) {}
}
/**
* Called when Field using this Fieldtype has been saved
*
* This is primarily so that Fieldtype modules can identify when their fields are
* saved without having to add a hook to the $fields API var.
*
* @param Field $field
* @since 3.0.171
*
*/
public function ___savedField(Field $field) {
}
/**
* Get a property from this Fieldtypes data
*