FormActionType
The FormActionType
represents an action rendered as a submit button to a hidden form, which allows the action to use any HTTP method.
Options
action
- type:
string
orcallable
- default:
'#'
Sets the value that will be used as a form's action
attribute.
use Kreyu\Bundle\DataTableBundle\Action\Type\FormActionType;
$builder
->addAction('send', FormActionType::class, [
'action' => $this->urlGenerator->generate('sms_send'),
])
;
method
- type:
string
orcallable
- default:
'GET'
Sets the value that will be used as a form's method
attribute.
use Kreyu\Bundle\DataTableBundle\Action\Type\FormActionType;
$builder
->addAction('send', FormActionType::class, [
'method' => 'POST',
])
;
button_attr
- type:
array
orcallable
- default:
[]
An array of attributes used to render the form submit button.
use Kreyu\Bundle\DataTableBundle\Action\Type\ButtonActionType;
$builder
->addAction('remove', ButtonActionType::class, [
'button_attr' => [
'class' => 'btn btn-danger',
],
])
;
Inherited options
label
- type:
null
,string
orSymfony\Component\Translation\TranslatableInterface
- default:
null
A label representing the action. When value equals null
, a sentence cased action name is used as a label, for example:
Action name | Guessed label |
---|---|
create | Create |
saveAndClose | Save and close |
label_translation_parameters
- type:
array
- default:
[]
An array of parameters used to translate the action label.
translation_domain
- type:
false
orstring
- default:
'KreyuDataTable'
Translation domain used in translation of action's translatable values.
block_prefix
- type:
string
- default: value returned by the action type
getBlockPrefix()
method
Allows you to add a custom block prefix and override the block name used to render the action type. Useful, for example, if you have multiple instances of the same action type, and you need to personalize the rendering of some of them, without the need to create a new action type.
visible
- type:
bool
orcallable
- default:
true
Determines whether the action should be visible to the user.
The callable can only be used by the row actions to determine visibility based on the row data:
use Kreyu\Bundle\DataTableBundle\Action\Type\ButtonActionType;
$builder
->addRowAction('remove', ButtonActionType::class, [
'visible' => function (Product $product) {
return $product->isRemovable();
},
])
;
attr
- type:
array
- default:
[]
An array of attributes used to render the action.
use Kreyu\Bundle\DataTableBundle\Action\Type\ButtonActionType;
$builder
->addAction('remove', ButtonActionType::class, [
'attr' => [
'class' => 'bg-danger',
],
])
;
icon_attr
- type:
array
- default:
[]
An array of attributes used to render the action's icon.
use Kreyu\Bundle\DataTableBundle\Action\Type\ButtonActionType;
$builder
->addAction('remove', ButtonActionType::class, [
'icon_attr' => [
'class' => 'ti ti-trash',
],
])
;
confirmation
- type:
bool
,array
orcallable
- default:
false
Determines whether the action is confirmable, which displays a modal where user have to acknowledge the process. The modal can be configured by passing an array with the following options:
translation_domain
- type:
false
orstring
- default:
'KreyuDataTable'
label_title
- type:
null
orstring
- default:
'Action confirmation'
label_description
- type:
null
orstring
- default:
'Are you sure you want to execute this action?'
label_confirm
- type:
null
orstring
- default:
'Confirm'
label_cancel
- type:
null
orstring
- default:
'Cancel'
type
- type:
null
orstring
- default:
danger
- allowed values:
danger
,warning
,info
Represents a type of the action confirmation, which determines the color of the displayed modal.