> For the complete documentation index, see [llms.txt](https://cbwire.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cbwire.ortusbooks.com/template-directives/wire-submit.md).

# wire:submit

The `wire:submit` directive provides a seamless way to handle form submissions in your CBWIRE components. Instead of dealing with traditional form processing and page refreshes, `wire:submit` intercepts form submissions and calls your component methods directly, creating smooth, dynamic form experiences.

## Basic Usage

This contact form demonstrates `wire:submit` with form handling and loading states:

{% tabs %}
{% tab title="BoxLang" %}

```javascript
// wires/ContactForm.bx
class extends="cbwire.models.Component" {
    data = {
        "name": "",
        "email": ""
    };

    function submit() {
        // Process form (simulate processing)
        sleep(1000);
        
        // Reset form
        data.name = "";
        data.email = "";
    }
}
```

{% endtab %}

{% tab title="CFML" %}

```javascript
// wires/ContactForm.cfc
component extends="cbwire.models.Component" {
    data = {
        "name" = "",
        "email" = ""
    };

    function submit() {
        // Process form (simulate processing)
        sleep(1000);
        
        // Reset form
        data.name = "";
        data.email = "";
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="BoxLang" %}

```html
<!-- wires/contactForm.bxm -->
<bx:output>
<form wire:submit="submit">
    <input type="text" wire:model="name" placeholder="Your Name">
    <input type="email" wire:model="email" placeholder="Email">
    
    <button type="submit">
        Send
        <span wire:loading>ing...</span>
    </button>
</form>
</bx:output>
```

{% endtab %}

{% tab title="CFML" %}

```html
<!-- wires/contactForm.cfm -->
<cfoutput>
<form wire:submit="submit">
    <input type="text" wire:model="name" placeholder="Your Name">
    <input type="email" wire:model="email" placeholder="Email">
    
    <button type="submit">
        Send
        <span wire:loading>ing...</span>
    </button>
</form>
</cfoutput>
```

{% endtab %}
{% endtabs %}

## What wire:submit Does

When you add `wire:submit` to a form, CBWIRE automatically:

* **Prevents Default Submission**: Stops the browser from submitting the form traditionally
* **Calls Your Method**: Executes the specified component method when the form is submitted
* **Disables Form Elements**: Automatically disables submit buttons and marks form inputs as readonly during processing
* **Maintains State**: Keeps all your component data intact during the submission process

## Available Modifiers

You can customize form submission behavior with these modifiers:

* **Prevent**: `.prevent` - Explicitly prevent default form submission (default behavior)

Example: `wire:submit.prevent="saveUser"`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cbwire.ortusbooks.com/template-directives/wire-submit.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
