Skip to content

Commit

Permalink
Improve function setDisabled()
Browse files Browse the repository at this point in the history
This commit removes deleting value of disabled form control. The reason why deleting value was implemented in this method is from is unclear and is now obsolete. Deleting value of the control makes use of the method complicated and tricky while the deleting itself has no real meaning.
  • Loading branch information
mildabre authored and dg committed Apr 27, 2024
1 parent 5442aae commit 9b89b71
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Forms/Controls/BaseControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ public function setDefaultValue($value): static
/**
* Disables or enables control.
*/
public function setDisabled(bool $value = true): static
{
if ($this->disabled = (bool) $value) {
$this->setValue(null);
} elseif (($form = $this->getForm(false)) && $form->isAnchored() && $form->isSubmitted()) {
$this->loadHttpData();
}
public function setDisabled(bool $value = true)
{
$justEnabled = $this->disabled && $value === false;
$this->disabled = $value;
if($justEnabled && ($form = $this->getForm(false)) && $form->isAnchored() && $form->isSubmitted()){
$this->loadHttpData();
}
return $this;
}

return $this;
}


/**
Expand Down

0 comments on commit 9b89b71

Please sign in to comment.