Skip to content

Commit

Permalink
FormElements: Introduce clearPopulatedValue()
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Feb 1, 2022
1 parent 455a955 commit 15d3107
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/FormElement/FormElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,22 @@ public function getPopulatedValue($name, $default = null)
: $default;
}

/**
* Clear populated value of the given element
*
* @param string $name
*
* @return $this
*/
public function clearPopulatedValue($name)
{
if (! $this->hasBeenSubmitted() && isset($this->populatedValues[$name])) {
unset($this->populatedValues[$name]);
}

return $this;
}

/**
* Add all elements from the given element collection
*
Expand Down

0 comments on commit 15d3107

Please sign in to comment.