generated from yiisoft/package-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docs about
ResetButton
widget (#125)
- Loading branch information
1 parent
48a1596
commit 98ad449
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | `''` |