Skip to main content

SchemaAction

Renders a form for a non-CRUD action — approve, publish, bulk process — and submits it to the action endpoint.

An action that needs input from the user gets this view. An action that needs none is just a button; it does not open a form at all.

Example​

<SchemaAction
actionName="publish"
params={{channel: 'web'}}
onPostSubmit={() => notify('Published')}
/>

Props​

On top of these it accepts React Admin's CreateProps except children.

NameTypeDefaultDescription
actionNamestring—Action identifier from the resource schema
namestring'action'Name of the action view
childrenReactNodegenerated formReplaces the generated inputs
onSubmitSubmitHandler<FieldValues>default action callTakes over submitting entirely
onPostSubmit() => void—Runs after a successful submit
paramsRecord<string, string>—Extra parameters sent with the request
caution

SchemaAction does not take title, toolbarActions or formActions as props. It reads them from the action's view schema (label, detail.toolbarActions) and renders SchemaFormActions; customise through children.

How the form is built​

The action's own schema — fetched from …/{id}/{action}/schema/ for a per-record action — carries the fields to collect. That is why the same action can ask for different inputs on different records, and why an action a user may not run simply does not appear in their schema.

A response carrying meta.state: "running" turns the action into a background task: the UI polls for its result and notifies on each state change, see useCallAction.

See also​