Skip to content

Commit

Permalink
Merge pull request #235 from raveren/main
Browse files Browse the repository at this point in the history
Fix value omitted when input created with no name
  • Loading branch information
freekmurze authored Jul 3, 2024
2 parents 10f40ba + 72066a9 commit c7f4e6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function element($tag)
*/
public function input($type = null, $name = null, $value = null)
{
$hasValue = $name && ($type !== 'password' && ! is_null($this->old($name, $value)) || ! is_null($value));
$hasValue = ! is_null($value) || ($type !== 'password' && ! is_null($this->old($name, $value)));

return Input::create()
->attributeIf($type, 'type', $type)
Expand Down
7 changes: 7 additions & 0 deletions tests/Html/InputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
);
});

it('can create an input with no name and a value', function () {
assertHtmlStringEqualsHtmlString(
'<input type="text" value="bar">',
$this->html->input('text', null, 'bar')
);
});

it('can create an input with a placeholder', function () {
assertHtmlStringEqualsHtmlString(
'<input placeholder="Foo bar">',
Expand Down

0 comments on commit c7f4e6f

Please sign in to comment.