Skip to content

Commit

Permalink
BaseControl: fixed un-omitting disabled controls [ref #90]
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 authored and dg committed Apr 1, 2016
1 parent 97a6638 commit fa84d63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Forms/Controls/BaseControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}


Expand Down
6 changes: 6 additions & 0 deletions tests/Forms/Forms.omittedValue.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Nette\Forms\Form;
use Nette\Utils\ArrayHash;
use Nette\Forms\Controls\TextInput;
use Tester\Assert;


Expand All @@ -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());

0 comments on commit fa84d63

Please sign in to comment.