Last active
December 18, 2018 10:11
-
-
Save flydev-fr/767669a226df380fd0c1000a4d43e4e6 to your computer and use it in GitHub Desktop.
↪️ Hook to add FieldtypeDecimal to compatible fieldtypes of a FieldtypeFloat when a superuser need to change the type of an existing float field - ProcessWire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Hook : place this hook in admin.php | |
* | |
* Add FieldtypeDecimal to compatible fieldtypes of | |
* a FieldtypeFloat when a superuser need to change the type | |
* of a float field. | |
* | |
* https://modules.processwire.com/modules/fieldtype-decimal/ | |
* https://processwire.com/talk/topic/7542-development-fieldtypefloat-fieldtypedecimal/ | |
* | |
*/ | |
$wire->addHookAfter('FieldtypeFloat::getCompatibleFieldtypes', function($event) { | |
if(!$this->modules->isInstalled('FieldtypeDecimal') || !$this->user->isSuperuser()) return; | |
$return = $event->return; | |
$return->set('FieldtypeDecimal', $this->modules->get('FieldtypeDecimal')); | |
$event->return = $return; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment