Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix input value is not populated when rules are applied #17

Merged
merged 1 commit into from
Sep 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/AbstractForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions tests/AbstractAuraFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<input id="name" type="text" name="name" value="@invalid@" />';
$this->assertContains($expected, $html);
}
}
16 changes: 0 additions & 16 deletions tests/Fake/FakeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down