x
1
2
3
4
5
6
<form data-controller="form" data-action="change->form#submit" action="/slow_action" accept-charset="UTF-8" method="post"><input type="hidden" name="authenticity_token" value="Q5QMdc-LoyCeWSj4kqmUnkLGzB_Vp5tYzmxlKgchIF-p_NH0eGRR1-py3J3zuOXOfRKJUKWQXuzEzYHePLoe2g" autocomplete="off" /> <div class="flex items-center gap"> <input name="status" type="hidden" value="0" autocomplete="off" /><input class="switch" role="switch" type="checkbox" value="1" name="status" id="status" /> <label class="text-sm font-medium" for="status">Airplane Mode</label> </div></form>
1
2
3
4
5
6
<%= form_with url: main_app.slow_action_path, data: { controller: "form", action: "change->form#submit" } do |form| %> <div class="flex items-center gap"> <%= form.checkbox :status, checked: false, class: "switch", role: "switch" %> <%= form.label :status, "Airplane Mode", class: "text-sm font-medium" %> </div><% end %>
CSS is not required or multiple files are needed, check the notes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { Controller } from "@hotwired/stimulus"export default class extends Controller { static targets = [ "cancel" ] submit() { this.element.requestSubmit() } cancel() { this.cancelTarget?.click() } preventAttachment(event) { event.preventDefault() }}
No notes provided.