diff --git a/src/AbstractForm.php b/src/AbstractForm.php index 0a19018..c4a2d84 100644 --- a/src/AbstractForm.php +++ b/src/AbstractForm.php @@ -131,6 +131,7 @@ public function apply(array $data) if ($this->antiCsrf && ! $this->antiCsrf->isValid($data)) { throw new CsrfViolationException; } + $this->fill($data); $isValid = $this->filter->apply($data); return $isValid; diff --git a/tests/AbstractAuraFormTest.php b/tests/AbstractAuraFormTest.php index ce5af04..33ae3be 100644 --- a/tests/AbstractAuraFormTest.php +++ b/tests/AbstractAuraFormTest.php @@ -43,5 +43,17 @@ public function testError() $this->assertFalse($isValid); $error = $this->form->error('name'); $this->assertSame('Name must be alphabetic only.', $error); + $html = (string) $this->form; + + return $html; + } + + /** + * @depends testError + */ + public function tesetInputDataReamainedOnValidationFailure($html) + { + $expected = ''; + $this->assertContains($expected, $html); } } diff --git a/tests/Fake/FakeForm.php b/tests/Fake/FakeForm.php index b25d5e5..94cc9a9 100644 --- a/tests/Fake/FakeForm.php +++ b/tests/Fake/FakeForm.php @@ -44,24 +44,8 @@ public function __toString() { $form = $this->form(); // name - $form .= $this->helper->tag('div', ['class' => 'form-group']); - $form .= $this->helper->tag('label', ['for' => 'name']); - $form .= 'Name:'; - $form .= $this->helper->tag('/label') . PHP_EOL; $form .= $this->input('name'); $form .= $this->error('name'); - $form .= $this->helper->tag('/div') . PHP_EOL; - // message - $form .= $this->helper->tag('div', ['class' => 'form-group']); - $form .= $this->helper->tag('label', ['for' => 'message']); - $form .= 'Message:'; - $form .= $this->helper->tag('/label') . PHP_EOL; - $form .= $this->input('message'); - $form .= $this->error('message'); - $form .= $this->helper->tag('/div') . PHP_EOL; - // submit - $form .= $this->input('submit'); - $form .= $this->helper->tag('/form'); return $form; }