Skip to content

Commit

Permalink
Merge pull request #8 from AReveron/feature/improve-load-form-moneyhe…
Browse files Browse the repository at this point in the history
…lper

Improved the load of the FormHelper in the MoneyHelper
  • Loading branch information
steinkel authored Mar 29, 2024
2 parents bc63e04 + 0c703a4 commit 1ed42df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/View/Helper/MoneyHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1ed42df

Please sign in to comment.