Skip to content

useModelAction ​

Overview ​

Provides target, execution, copy, dry-run, and redirect plumbing for model actions. It does not create or consume a form context; form shells layer useActionForm or ActionForm on top when they need submit UI and validation summaries.

Signature ​

useModelAction(props)

Parameters ​

NameTypeRequiredDescription
propsobjectyesReactive action configuration.

props Properties ​

NameTypeRequiredDefaultDescription
actionstringAction identifier sent to the server.
actionErrorSummarystringToast summary shown when the action fails.
actionSuccessSummarystringToast summary shown on successful action completion.
actionVerboseNamestringHuman-readable action name.
appstringDjango app label that owns the model.
bannerDescriptionstringOptional banner description.
bannerTitlestringOptional banner title.
confirmMessagestringConfirmation message shown to the user before submitting.
enableDryRunbooleanWhether to perform dry-run validation.
fetchStateobjectSelected-object fetch state.
instanceListobject | objectList instance that holds the selected objects. Bulk actions use it to reconcile displayed rows after a real destroy. Omit it to use a private transport-only list.
modelstringDjango model name the action targets.
pkstring | number | string[] | number[]Optional primary key or primary keys when no fetch state is ready.
requestMethodstringHTTP method used for non-destroy action requests.
tone"neutral" | "info" | "warning" | "success" | "danger"Sentiment tone.
transformSubmitDataFn(values: any) => anyOptional form-value transform.

Returns ​

ModelActionContext

Source ​

client/lib/use/useModelAction.js:103