diff --git a/CHANGELOG.md b/CHANGELOG.md index 459e015..274b060 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + * Improved the load of the FormHelper in the MoneyHelper ## [2.0.2] 2024-03-01 - improved conde completion in `\CakeDC\Money\Money` class diff --git a/src/View/Helper/MoneyHelper.php b/src/View/Helper/MoneyHelper.php index 706bde7..10073fc 100644 --- a/src/View/Helper/MoneyHelper.php +++ b/src/View/Helper/MoneyHelper.php @@ -35,7 +35,12 @@ class MoneyHelper extends Helper */ public function initialize(array $config): void { - $this->getView()->loadHelper('Form', ['typeMap' => ['money' => 'money']]); + if ($this->getView()->helpers()->has('Form')) { + $this->getView()->helpers()->get('Form')->setConfig('typeMap', ['money' => 'money']); + } else { + $this->getView()->loadHelper('Form', ['typeMap' => ['money' => 'money']]); + } + $this->getView()->Form->addWidget('money', ['CakeDC/Money.Money']); parent::initialize($config);