Using protected properties on form actions
Is it safe to store a protected property on a form action?
class MyFormAction extends Action
{
protected bool $myOption = false;
protected function setUp(): void
{
parent::setUp();
$this->label('My Action')
->action(function () {
if ($this->myOption) {
// ...
} else {
// ...
}
});
}
public function myOption(bool $myOption = true): static
{
$this->myOption = $myOption;
return $this;
}
}class MyFormAction extends Action
{
protected bool $myOption = false;
protected function setUp(): void
{
parent::setUp();
$this->label('My Action')
->action(function () {
if ($this->myOption) {
// ...
} else {
// ...
}
});
}
public function myOption(bool $myOption = true): static
{
$this->myOption = $myOption;
return $this;
}
}