Skip to content

Commit

Permalink
Add docs about ResetButton widget (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Oct 28, 2021
1 parent 48a1596 commit 98ad449
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -45,6 +45,7 @@ The following documentation describes how to use widgets with PHP:
- [Radio](docs/radio.md)
- [RadioList](docs/radiolist.md)
- [Range](docs/range.md)
- [ResetButton](docs/resetbutton.md)
- [SubmitButton](docs/submitbutton.md)
- [Text](docs/text.md)
- [Telephone](docs/telephone.md)
Expand Down
51 changes: 51 additions & 0 deletions docs/resetbutton.md
@@ -0,0 +1,51 @@
# Reset button widget

[ResetButton](https://www.w3.org/TR/2012/WD-html-markup-20120329/input.reset.html#input.reset) represents a button for resetting a form.

## Usage

Widget view:

```php
<?php

declare(strict_types=1);

use Yiisoft\Form\Widget\Field;
use Yiisoft\Form\Widget\Form;
use Yiisoft\Form\Widget\ResetButton;

/**
* @var object $csrf
*/
?>

<?= Form::widget()->action('widgets')->csrf($csrf)->begin(); ?>
<?= ResetButton::widget()->value('Reset Form'); ?>
<hr class="mt-3">
<?= Field::widget()->submitButton(['class' => 'button is-block is-info is-fullwidth', 'value' => 'Save']); ?>
<?= Form::end(); ?>
```

That would generate the following code:

```html
<form action="widgets" method="POST" _csrf="LB8wetUt2ESCosrpbO1wsJEj1UQMxhK9RPyY0wExq9lIckEo50GbJbbT860zgACCy1C-aTWNfs50kcybWELGlQ==">
<input type="hidden" name="_csrf" value="LB8wetUt2ESCosrpbO1wsJEj1UQMxhK9RPyY0wExq9lIckEo50GbJbbT860zgACCy1C-aTWNfs50kcybWELGlQ==">
<input type="reset" id="reset-10194484223001" name="reset-10194484223001" value="Reset Form">
<hr class="mt-3">
<div>
<input type="submit" id="submit-10194493875001" class="button is-block is-info is-fullwidth" name="submit-10194493875001" value="Save">
</div>
</form>
```

### `Common` methods:

Method | Description | Default
-------|-------------|---------
`autoIdPrefix(string $value)` | Sets the prefix for generating automatic IDs | `'reset-'`
`attributes(array $value)` | Sets the HTML attributes | `[]``
`id(string $id)` | Sets the ID attribute | `''`
`name(string $name)` | Sets the name attribute | `''`
`value(string $value)` | Sets the value attribute | `''`

0 comments on commit 98ad449

Please sign in to comment.