Skip to content

Commit

Permalink
Merge pull request #221 from raveren/main
Browse files Browse the repository at this point in the history
Add autocomplete attribute helper to the form element
  • Loading branch information
freekmurze authored Apr 19, 2024
2 parents 1847be1 + ad42d08 commit e611cac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/general-usage/element-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ echo Element::withTag('p')->text('This is the content!');

- `function acceptsFiles()`
- `function action(?string $action)`
- `function autocomplete(bool|string $autocomplete = true)`
- `function method(?string $method)`
- `function novalidate($novalidate = true)`
- `function target(string $target)`
Expand All @@ -66,7 +67,7 @@ echo Element::withTag('p')->text('This is the content!');

## `Input`

- `function autocomplete(?$autocomplete)`
- `function autocomplete(bool|string $autocomplete = true)`
- `function autofocus(?$autofocus)`
- `function checked($checked = true)`
- `function disabled($disabled = true)`
Expand Down Expand Up @@ -104,7 +105,7 @@ echo Element::withTag('p')->text('This is the content!');

## `Select`

- `function autocomplete(?$autocomplete)`
- `function autocomplete(bool|string $autocomplete = true)`
- `function autofocus(?$autofocus)`
- `function disabled(?$disabled)`
- `function isReadonly(?$readonly)`
Expand All @@ -120,7 +121,7 @@ echo Element::withTag('p')->text('This is the content!');

## `Textarea`

- `function autocomplete(?$autocomplete)`
- `function autocomplete(bool|string $autocomplete = true)`
- `function autofocus()`
- `function cols(int $cols)`
- `function disabled(?$disabled)`
Expand Down
2 changes: 2 additions & 0 deletions src/Elements/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace Spatie\Html\Elements;

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

class Form extends BaseElement
{
use Autocomplete;
use Target;

protected $tag = 'form';
Expand Down
6 changes: 6 additions & 0 deletions tests/Elements/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
Form::create()->acceptsFiles()
);

it('can create a form with a non-autocomplete attribute')
->assertHtmlStringEqualsHtmlString(
'<form autocomplete="off"></form>',
Form::create()->autocomplete(false)
);

it('can create a form with a novalidate attribute')
->assertHtmlStringEqualsHtmlString(
'<form enctype="multipart/form-data" novalidate=""></form>',
Expand Down

0 comments on commit e611cac

Please sign in to comment.