Skip to content

Commit

Permalink
Add docs for SubmitButton widget (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Oct 28, 2021
1 parent 106e148 commit 3d7a413
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -139,6 +139,7 @@ The following documentation describes how to use widgets with PHP:
- [Radio](docs/radio.md)
- [RadioList](docs/radiolist.md)
- [Range](docs/range.md)
- [SubmitButton](docs/submitbutton.md)
- [Text](docs/text.md)
- [Telephone](docs/telephone.md)
- [Url](docs/url.md)
Expand Down
44 changes: 44 additions & 0 deletions docs/submitbutton.md
@@ -0,0 +1,44 @@
# Submit button widget

[SubmitButton](https://www.w3.org/TR/2012/WD-html-markup-20120329/input.submit.html) represents a button for submitting a form.

## Usage

Widget view:

```php
<?php

declare(strict_types=1);

use Yiisoft\Form\Widget\Form;
use Yiisoft\Form\Widget\SubmitButton;

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

<?= Form::widget()->action('widgets')->csrf($csrf)->begin(); ?>
<?= SubmitButton::widget()->attributes(['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="submit" id="submit-10194493875001" class="button is-block is-info is-fullwidth" name="submit-10194493875001" value="Save">
</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 3d7a413

Please sign in to comment.