Skip to content

Commit

Permalink
fixes #686: alterFieldValues() in all ParentType bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
rudiedirkx committed Apr 8, 2022
1 parent f424309 commit ca25ed8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
17 changes: 17 additions & 0 deletions src/Kris/LaravelFormBuilder/Fields/CollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ public function getAllAttributes()
return $this->parent->getFormHelper()->mergeAttributes($this->children);
}

/**
* Allow form-specific value alters.
*
* @param array $values
* @return void
*/
public function alterFieldValues(array &$values)
{
foreach ($this->children as $i => $child) {
if (method_exists($child, 'alterFieldValues')) {
if (isset($values[$i])) {
$child->alterFieldValues($values[$i]);
}
}
}
}

/**
* @inheritdoc
*/
Expand Down
17 changes: 0 additions & 17 deletions src/Kris/LaravelFormBuilder/Fields/ParentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,4 @@ public function getValidationRules()

return $rules->append($childrenRules);
}

/**
* Allow form-specific value alters.
*
* @param array $values
* @return void
*/
public function alterFieldValues(array &$values)
{
foreach ($this->children as $i => $child) {
if (method_exists($child, 'alterFieldValues')) {
if (isset($values[$i])) {
$child->alterFieldValues($values[$i]);
}
}
}
}
}

0 comments on commit ca25ed8

Please sign in to comment.