Skip to content

Commit

Permalink
Merge pull request #223 from bskl/add-name-attr-to-form
Browse files Browse the repository at this point in the history
Add name attribute to form element
  • Loading branch information
freekmurze authored Apr 24, 2024
2 parents 2e2f81c + 1b5bce9 commit f1dcd29
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Elements/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

use Spatie\Html\BaseElement;
use Spatie\Html\Elements\Attributes\Autocomplete;
use Spatie\Html\Elements\Attributes\Name;
use Spatie\Html\Elements\Attributes\Target;

class Form extends BaseElement
{
use Autocomplete;
use Name;
use Target;

protected $tag = 'form';
Expand Down
7 changes: 7 additions & 0 deletions tests/Elements/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@
'<form target="_blank"></form>',
Form::create()->target('_blank')
);

it('can create a form with a name', function () {
assertHtmlStringEqualsHtmlString(
'<form name="form-name"></form>',
Form::create()->name('form-name')
);
});
7 changes: 7 additions & 0 deletions tests/Html/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,10 @@
it('can return close model form')
->expect(fn () => (string) $this->html->closeModelForm())
->toEqual('</form>');

it('can create a form with a name', function () {
assertHtmlStringEqualsHtmlString(
'<form method="GET" name="form-name"></form>',
$this->html->form('GET')->name('form-name')
);
});

0 comments on commit f1dcd29

Please sign in to comment.