Sometimes you have a small little class like Rate.php and want to use it with a symfony form like:
$builder
->add('cost', MoneyType::class, [
'currency' => 'EUR',
'label' => 'Cost',
'divisor' => 100,
]);
But S*** symfony forms expects a set<name>
method. Let's change this behaviour by using a custom property accessor and overriding the path.
$builder
->setDataMapper(new PropertyPathMapper(
new CustomPropertyAccessor([ 'cost' => 'changeCost' ])
));
All done.
@ostrolucky 'property_path' is not for this