Skip to content

Commit

Permalink
Pass encoded property values when updating model
Browse files Browse the repository at this point in the history
  • Loading branch information
discordier committed Jul 17, 2024
1 parent ad092d0 commit 3859182
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ public function __construct(EnvironmentInterface $environment, ModelInterface $m
/**
* Encode a value from the widget to native data of the data provider via event.
*
* @param string $property The property.
* @param mixed $value The value of the property.
* @param PropertyValueBag $propertyValues The property value bag the property value originates from.
* @param string $property The property.
* @param mixed $value The value of the property.
* @param PropertyValueBagInterface $propertyValues The property value bag the property value originates from.
*
* @return mixed
*/
public function encodeValue($property, $value, PropertyValueBag $propertyValues)
public function encodeValue($property, $value, PropertyValueBagInterface $propertyValues)
{
$environment = $this->getEnvironment();
$dispatcher = $environment->getEventDispatcher();
Expand Down Expand Up @@ -303,7 +303,14 @@ public function getWidget($property, PropertyValueBagInterface $inputValues = nu
$controller = $environment->getController();
assert($controller instanceof ControllerInterface);

$values = new PropertyValueBag($inputValues->getArrayCopy());
$values = new PropertyValueBag();
foreach ($inputValues->getIterator() as $propertyName => $propertyValue) {
$values->setPropertyValue(
$propertyName,
$this->encodeValue($propertyName, $propertyValue, $inputValues)
);
}

$controller->updateModelFromPropertyBag($model, $values);
}

Expand Down

0 comments on commit 3859182

Please sign in to comment.