diff --git a/src/Forms/Controls/BaseControl.php b/src/Forms/Controls/BaseControl.php index 2adf487e5..806861cac 100644 --- a/src/Forms/Controls/BaseControl.php +++ b/src/Forms/Controls/BaseControl.php @@ -52,8 +52,8 @@ abstract class BaseControl extends Nette\ComponentModel\Component implements ICo /** @var bool */ protected $disabled = FALSE; - /** @var bool */ - private $omitted = FALSE; + /** @var bool|NULL */ + private $omitted; /** @var Nette\Forms\Rules */ private $rules; @@ -225,7 +225,7 @@ public function setOmitted($value = TRUE) */ public function isOmitted() { - return $this->omitted || $this->disabled; + return $this->omitted || ($this->disabled && $this->omitted === NULL); } diff --git a/tests/Forms/Forms.omittedValue.phpt b/tests/Forms/Forms.omittedValue.phpt index 08af83cdc..d9f24a60c 100644 --- a/tests/Forms/Forms.omittedValue.phpt +++ b/tests/Forms/Forms.omittedValue.phpt @@ -6,6 +6,7 @@ use Nette\Forms\Form; use Nette\Utils\ArrayHash; +use Nette\Forms\Controls\TextInput; use Tester\Assert; @@ -19,3 +20,8 @@ $form->addText('omittedInput') ->setOmitted(); Assert::same(['input' => ''], $form->getValues(TRUE)); + + +Assert::true((new TextInput)->setDisabled()->isOmitted()); +Assert::false((new TextInput)->setDisabled()->setDisabled(FALSE)->isOmitted()); +Assert::false((new TextInput)->setDisabled()->setOmitted(FALSE)->isOmitted());