<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Validation Example</title>
<style>
import { Application } from "@hotwired/stimulus"
import FormSubmitController from "./controllers/form_submit_controller"
const application = Application.start()
application.debug = false
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static values = {
url: String,
delay: { type: Number, default: 800 },
import axios from 'axios';
export type NormalizedErrors = {
fields: Record<string, string>;
formLevel: string | null;
};
class SubscriptionsController < ApplicationController
def new
@subscription = current_account.subscriptions.new
end
def create
import { useForm } from 'react-hook-form'
import { PostFormData } from '@/types'
interface PostFormProps {
initialData?: Partial<PostFormData>
onSubmit: (data: PostFormData) => Promise<void>
class PostsController < ApplicationController
def new
@post = Post.new
end
def create
<%= form_with url: autosave_draft_path,
method: :post,
local: false,
data: {
controller: "autosave",
autosave_target: "form",
class Recipe < ApplicationRecord
has_many :ingredients, inverse_of: :recipe, dependent: :destroy
accepts_nested_attributes_for :ingredients,
allow_destroy: true,
reject_if: :all_blank
<!DOCTYPE html>
<html>
<head>
<title>Contacts</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
class AtLeastOneOfValidator < ActiveModel::Validator
def validate(record)
fields = Array(options[:fields])
raise ArgumentError, "provide :fields" if fields.empty?
return if fields.any? { |field| filled?(record.public_send(field)) }
<h1>Products</h1>
<%= link_to "New product", new_product_path, data: { turbo_frame: "modal" }, class: "btn" %>
<table id="products">
<tbody>