Skip to content
This repository has been archived by the owner on Nov 8, 2020. It is now read-only.

Commit

Permalink
Missing field only for not disabled inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
klapuch committed May 10, 2017
1 parent 3d4f9fa commit d9283b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Core/DefaultInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
public function validate(): void {
$name = $this->attributes['name'];
$this->storage->archive($name);
if (!isset($this->storage[$name])) {
if (!isset($this->storage[$name]) && !isset($this->attributes['disabled'])) {
throw new \UnexpectedValueException(
sprintf('Field "%s" is missing in sent data', $name)
);
Expand Down
11 changes: 11 additions & 0 deletions Tests/Unit/DefaultInput.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ final class DefaultInput extends Tester\TestCase {
))->validate();
}

public function testPassingWithDisabledInput() {
Assert::noError(function() {
$backup = [];
(new Form\DefaultInput(
['name' => 'surname', 'disabled' => 'true'],
new Form\Backup($backup, ['foo' => 'bar']),
new Validation\FakeRule(null, null)
))->validate();
});
}

public function testReloadingStatedValueAfterWrongValidation() {
$storage = [];
Assert::same(
Expand Down

0 comments on commit d9283b5

Please sign in to comment.