Skip to content

Commit f2d0e3a

Browse files
committed
Merge pull request #17 from koriym/value
fix input value is not populated when rules are applied
2 parents 1afcfd2 + 30ac55d commit f2d0e3a

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

src/AbstractForm.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public function apply(array $data)
131131
if ($this->antiCsrf && ! $this->antiCsrf->isValid($data)) {
132132
throw new CsrfViolationException;
133133
}
134+
$this->fill($data);
134135
$isValid = $this->filter->apply($data);
135136

136137
return $isValid;

tests/AbstractAuraFormTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,17 @@ public function testError()
4343
$this->assertFalse($isValid);
4444
$error = $this->form->error('name');
4545
$this->assertSame('Name must be alphabetic only.', $error);
46+
$html = (string) $this->form;
47+
48+
return $html;
49+
}
50+
51+
/**
52+
* @depends testError
53+
*/
54+
public function tesetInputDataReamainedOnValidationFailure($html)
55+
{
56+
$expected = '<input id="name" type="text" name="name" value="@invalid@" />';
57+
$this->assertContains($expected, $html);
4658
}
4759
}

tests/Fake/FakeForm.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,8 @@ public function __toString()
4444
{
4545
$form = $this->form();
4646
// name
47-
$form .= $this->helper->tag('div', ['class' => 'form-group']);
48-
$form .= $this->helper->tag('label', ['for' => 'name']);
49-
$form .= 'Name:';
50-
$form .= $this->helper->tag('/label') . PHP_EOL;
5147
$form .= $this->input('name');
5248
$form .= $this->error('name');
53-
$form .= $this->helper->tag('/div') . PHP_EOL;
54-
// message
55-
$form .= $this->helper->tag('div', ['class' => 'form-group']);
56-
$form .= $this->helper->tag('label', ['for' => 'message']);
57-
$form .= 'Message:';
58-
$form .= $this->helper->tag('/label') . PHP_EOL;
59-
$form .= $this->input('message');
60-
$form .= $this->error('message');
61-
$form .= $this->helper->tag('/div') . PHP_EOL;
62-
// submit
63-
$form .= $this->input('submit');
64-
$form .= $this->helper->tag('/form');
6549

6650
return $form;
6751
}

0 commit comments

Comments
 (0)