Skip to content
This repository has been archived by the owner on Feb 26, 2018. It is now read-only.

Commit

Permalink
Merge pull request #61 from irineujunior/patch-1
Browse files Browse the repository at this point in the history
Avoid to pass "_token" value through query string
  • Loading branch information
adamwathan committed Oct 10, 2015
2 parents ca96009 + 3ec14ee commit c71f293
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AdamWathan/Form/Elements/FormOpen.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function render()
$result .= $this->renderAttributes();
$result .= '>';

if ($this->hasToken()) {
if ($this->hasToken() && ($this->attributes['method'] !== 'GET')) {
$result .= $this->token->render();
}

Expand Down
8 changes: 8 additions & 0 deletions tests/FormBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ public function testTokenIsRenderedAutomaticallyOnOpenIfSet()
$this->assertEquals($expected, $result);
}

public function testTokenIsNotRenderedAutomaticallyOnOpenFormWithGetMethodIfSet()
{
$this->form->setToken('12345');
$expected = '<form method="GET" action="">';
$result = (string)$this->form->open()->get();
$this->assertEquals($expected, $result);
}

public function testSelectMonth()
{
$expected = '<select name="month"><option value="1">January</option><option value="2">February</option><option value="3">March</option><option value="4">April</option><option value="5">May</option><option value="6">June</option><option value="7">July</option><option value="8">August</option><option value="9">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select>';
Expand Down

0 comments on commit c71f293

Please sign in to comment.