-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
224 additions
and
53 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,15 +1,61 @@ | ||
{% set option_display_icon_default = 'false' %} | ||
|
||
# ButtonActionType | ||
|
||
The [:material-github: ButtonActionType](https://github.com/Kreyu/data-table-bundle/blob/main/src/Action/Type/ButtonActionType.php) represents an action displayed as a button. | ||
Uses [LinkActionType](./link.md) as parent. | ||
|
||
## Options | ||
|
||
This action type has no additional options. | ||
### `href` | ||
|
||
**type**: `string` or `callable` **default**: `'#'` | ||
|
||
Sets the value that will be used as a link `href` attribute (see [href attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href)). | ||
Closure can be used to provide an option value based on a row value, which is passed as a first argument. | ||
|
||
```php | ||
use Kreyu\Bundle\DataTableBundle\Action\Type\LinkActionType; | ||
|
||
$builder | ||
->addAction('show', LinkActionType::class, [ | ||
'href' => $this->urlGenerator->generate('category_show', [ | ||
'id' => $category->getId(), | ||
]), | ||
]) | ||
; | ||
``` | ||
|
||
### `target` | ||
|
||
**type**: `string` or `callable` **default**: `'_self'` | ||
|
||
Sets the value that will be used as an anchor `target` attribute (see [target attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target)). | ||
Closure can be used to provide an option value based on a row value, which is passed as a first argument. | ||
|
||
### `link_attr` | ||
|
||
**type**: `array` **default**: `[]` | ||
|
||
If you want to add extra attributes to an HTML representation of the button's link, you can use the link_attr option. | ||
It's an associative array with HTML attributes as keys. | ||
|
||
### `icon_attr` | ||
|
||
**type**: `array` **default**: `[]` | ||
|
||
If you want to add extra attributes to an HTML representation of the button's icon, you can use the icon_attr option. | ||
It's an associative array with HTML attributes as keys. | ||
|
||
```php | ||
use Kreyu\Bundle\DataTableBundle\Action\Type\ButtonActionType; | ||
|
||
$builder | ||
->addAction('remove', ButtonActionType::class, [ | ||
'icon_attr' => [ | ||
'class' => 'fa fa-trash', | ||
], | ||
]) | ||
; | ||
``` | ||
|
||
## Inherited options | ||
|
||
{% include-markdown "_link_options.md" heading-offset=2 %} | ||
{% include-markdown "_action_options.md" heading-offset=2 %} |
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,67 @@ | ||
# FormActionType | ||
|
||
The [:material-github: FormActionType](https://github.com/Kreyu/data-table-bundle/blob/main/src/Action/Type/FormActionType.php) represents an action displayed as a button wrapped in form. | ||
|
||
## Options | ||
|
||
### `action` | ||
|
||
**type**: `string` or `callable` **default**: `'#'` | ||
|
||
Sets the value that will be used as a form's `action` attribute. | ||
|
||
```php | ||
use Kreyu\Bundle\DataTableBundle\Action\Type\FormActionType; | ||
|
||
$builder | ||
->addAction('send', FormActionType::class, [ | ||
'action' => $this->urlGenerator->generate('sms_send'), | ||
]) | ||
; | ||
``` | ||
|
||
### `method` | ||
|
||
**type**: `string` or `callable` **default**: `'GET'` | ||
|
||
Sets the value that will be used as a form's `method` attribute. | ||
|
||
```php | ||
use Kreyu\Bundle\DataTableBundle\Action\Type\FormActionType; | ||
|
||
$builder | ||
->addAction('send', FormActionType::class, [ | ||
'method' => 'POST', | ||
]) | ||
; | ||
``` | ||
|
||
### `button_attr` | ||
|
||
**type**: `array` **default**: `[]` | ||
|
||
If you want to add extra attributes to an HTML representation of the form's submit button, you can use the button_attr option. | ||
It's an associative array with HTML attributes as keys. | ||
|
||
### `icon_attr` | ||
|
||
**type**: `array` **default**: `[]` | ||
|
||
If you want to add extra attributes to an HTML representation of the button's icon, you can use the icon_attr option. | ||
It's an associative array with HTML attributes as keys. | ||
|
||
```php | ||
use Kreyu\Bundle\DataTableBundle\Action\Type\FormActionType; | ||
|
||
$builder | ||
->addAction('send', FormActionType::class, [ | ||
'icon_attr' => [ | ||
'class' => 'fa fa-envelope', | ||
], | ||
]) | ||
; | ||
``` | ||
|
||
## Inherited options | ||
|
||
{% include-markdown "_action_options.md" heading-offset=2 %} |
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
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
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kreyu\Bundle\DataTableBundle\Action\Type; | ||
|
||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class FormActionType extends AbstractActionType | ||
{ | ||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver | ||
->setDefaults([ | ||
'method' => 'GET', | ||
'action' => '#', | ||
'button_attr' => [], | ||
'icon_attr' => [], | ||
]) | ||
->setAllowedTypes('method', ['string', 'callable']) | ||
->setAllowedTypes('action', ['string', 'callable']) | ||
->setAllowedTypes('button_attr', ['array', 'callable']) | ||
->setAllowedTypes('icon_attr', ['array', 'callable']) | ||
; | ||
} | ||
} |
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
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