Skip to content

Commit

Permalink
optimise hydrate
Browse files Browse the repository at this point in the history
  • Loading branch information
TomK committed Aug 24, 2020
1 parent 2944713 commit bb929c3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,15 @@ public function hydrate(array $data, $hydrateInvalidValues = false)
{
$keyedHandlers = Objects::mpull($this->_dataHandlers, null, 'getName');

$mergedFormData = array_merge($this->getFormData(), $data);
$keyedErrors = [];
foreach($data as $name => $value)
{
$ele = Arrays::value($keyedHandlers, $name);
if($ele instanceof DataHandler)
{
$value = $ele->formatValue($value);
$handlerErrors = $ele->validateValue($value, array_merge($this->getFormData(), $data));
$handlerErrors = $ele->validateValue($value, $mergedFormData);
if(empty($handlerErrors))
{
$ele->setValue($value);
Expand Down

0 comments on commit bb929c3

Please sign in to comment.