---
title: "on web action · RUAL Documentation"
description: "Runs when a button or form on a web page of this blueprint calls the action with this name (data-action=\"name\"). Answer with web replace, web remove, we…"
canonical: https://docs.rual.nl/block-types/web/web_action
language: en
---

# on web action

This block is part of the [`web`](https://docs.rual.nl/block-types/web) group and was last modified in core [`v15.0.1`](https://docs.rual.nl/core-versions/150001).

Runs when a button or form on a web page of this blueprint calls the action with this name (`data-action="name"`). Answer with `web replace`, `web remove`, `web insert`, `web update`, `web errors` or `web redirect`: only those parts of the page change.

- flow

- connection `httpconnection`

- form `object` The fields the form or button sent.

- key `value` The data-key of the element the action came from: which row was clicked.

- params `object`

- query `object`

- language `value`

Entry block of a web action, named by its `event` field. It is reached ONLY by a POST to a URL of a web_page in the same blueprint whose body carries `_action=<event>`. Admission: the posted page's scopes, AND the action's own `scopes` when it has any, else the scopes of EVERY web_page in the blueprint (a blueprint with a public and an admin page needs `scopes: ["*public"]` on an action the public page uses). A cross-site POST is refused. The browser runtime sends it for `<button data-action="name">`, `<form data-action="name">` and `<input data-action="name" data-trigger="input">`; a plain HTML form works too (`<input type=hidden name=_action value=name>`). Out-pins: form (object of the posted fields; a repeated name or a name ending in [] is an array; `_action` and `_key` removed), key (the data-key of the element closest to the button, i.e. which row was clicked; "" when none), connection, params, query, language. The flow answers by adding browser updates with web_replace/web_update/web_insert/web_remove/web_errors/web_redirect; they apply in order. A web_render here answers with a whole new page instead. No updates at all answers an empty update list (the page stays as it is). Without JavaScript the visitor is redirected back to the page (303) or to web_redirect's URL.

| `button click` |
| --- |
| `form submit` |
| `web form` |
| `on click` |

[on web action](https://docs.rual.nl/block-types/web/web_action) runs when a button or form on a web page of this blueprint calls it by the name in its `event` setting. The posted fields arrive on form, and key says which row was clicked: the data-key of the element closest to the button. [get fields](https://docs.rual.nl/block-types/object/object_field_getter_multiple) and [set fields](https://docs.rual.nl/block-types/mutations/mutations_set_bp_field_multiple) turn the form into mutations, [update document](https://docs.rual.nl/block-types/storage/function_update_document_mutations) writes them to the document with that guid, [web template](https://docs.rual.nl/block-types/web/web_template) renders the row again and [web replace](https://docs.rual.nl/block-types/web/web_replace) swaps it in. Only that row changes in the browser. An action with no update blocks leaves the page as it is.

[![Studio canvas example for the on web action block: saving an edited row.](https://docs.rual.nl/canvas-examples/web_action.png)](https://docs.rual.nl/canvas-examples/web_action.png?v=3)

## Used in these guides

These documentation pages use or explain this block:

- [Building a Dashboard with Charts](https://docs.rual.nl/tutorials/dashboard-charts)

- [Building a Login Page](https://docs.rual.nl/tutorials/login-page)

- [Building User Authentication](https://docs.rual.nl/tutorials/user-authentication)

- [Email System Setup](https://docs.rual.nl/tutorials/email-system)

- [File Upload & Processing](https://docs.rual.nl/tutorials/file-upload-processing)

- [Common Blueprint Patterns](https://docs.rual.nl/blueprints/common-patterns)

- [How Web Pages Work](https://docs.rual.nl/web/overview)

- [Languages](https://docs.rual.nl/web/languages)

## Version history

Introduced in [`v15.0.1`](https://docs.rual.nl/core-versions/150001).

- [`v15.0.1`](https://docs.rual.nl/core-versions/150001): block added in this release.

- [Back to `web`](https://docs.rual.nl/block-types/web): Return to the main group to view all sub-groups

- [Back to `web pages`](https://docs.rual.nl/block-types/web?group=web%20pages): Return to the group to view all blocks within this group
