Getting started
“Actions” are buttons that are displayed next to the page’s heading, and allow the user to run a Livewire method on the page or visit a URL. To define actions for a page, use thegetActions() method:
label() method:
url() method:
color(). The default is primary, but you may use secondary, success, warning, or danger:
size(). The default is md, but you may also use sm or lg:
icon(), which is the name of any Blade component. By default, the Blade Heroicons v1 package is installed, so you may use the name of any Heroicons v1 out of the box. However, you may create your own custom icon components or install an alternative library if you wish.
Modals
Actions may require additional confirmation or form information before they run. You may open a modal before an action is executed to do this.Confirmation modals
You may require confirmation before an action is run using therequiresConfirmation() method. This is useful for particularly destructive actions, such as those that delete records.
Note: The confirmation modal is not available when aurl()is set instead of anaction(). Instead, you should redirect to the URL within theaction()callback.
Custom forms
You may also render a form in this modal to collect extra information from the user before the action runs. You may use components from the Form Builder to create custom action modal forms. The data from the form is available in the$data array of the action() callback:
Filling default data
You may fill the form with default data, using themountUsing() method:
Setting a modal heading, subheading, and button label
You may customize the heading, subheading and button label of the modal:Custom content
You may define custom content to be rendered inside your modal, which you can specify by passing a Blade view into themodalContent() method:
modalFooter() if you wish:
Conditionally hiding the modal
You may have a need to conditionally show a modal for confirmation reasons while falling back to the default action. This can be achieved usingmodalHidden():
Grouping
You may use anActionGroup object to group multiple actions together in a dropdown:
Keybindings
You can attach keyboard shortcuts to actions. These use the same key codes as Mousetrap:Refreshing form data
If you’re using actions on an Edit or View resource page, you can refresh data within the main form using therefreshFormData() method: