Skip to content

Commit 040f31c

Browse files
committed
BaseControl: fixed un-omitting disabled controls [ref nette#90]
1 parent e9849ef commit 040f31c

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/Forms/Controls/BaseControl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ abstract class BaseControl extends Nette\ComponentModel\Component implements ICo
5252
/** @var bool */
5353
protected $disabled = FALSE;
5454

55-
/** @var bool */
56-
private $omitted = FALSE;
55+
/** @var bool|null */
56+
private $omitted;
5757

5858
/** @var Nette\Forms\Rules */
5959
private $rules;
@@ -225,7 +225,7 @@ public function setOmitted($value = TRUE)
225225
*/
226226
public function isOmitted()
227227
{
228-
return $this->omitted || $this->disabled;
228+
return $this->omitted || ($this->disabled && $this->omitted !== FALSE);
229229
}
230230

231231

tests/Forms/Forms.omittedValue.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,22 @@ $form->addText('omittedInput')
1919
->setOmitted();
2020

2121
Assert::same(['input' => ''], $form->getValues(TRUE));
22+
23+
24+
$form = new Form('name');
25+
$form->addText('input')
26+
->setDisabled()->setDisabled(FALSE);
27+
28+
Assert::same(['input' => ''], $form->getValues(TRUE));
29+
30+
$form = new Form('name');
31+
$form->addText('input')
32+
->setDisabled()->setOmitted(FALSE);
33+
34+
Assert::same(['input' => ''], $form->getValues(TRUE));
35+
36+
$form = new Form('name');
37+
$form->addText('input')
38+
->setDisabled();
39+
40+
Assert::same([], $form->getValues(TRUE));

0 commit comments

Comments
 (0)