x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<form class="flex flex-col gap-6 max-w-md" action="#" accept-charset="UTF-8" method="post"><input type="hidden" name="authenticity_token" value="65WkVDQCccBMfY4JNsRjrVWO0uXmi94ya2bUyRABliTh8zQz8cqS313uLGPfXOOuHLAOtGezgTOVPl_4XdkKJg" /> <div class="flex flex-col gap-2 w-full"> <label for="ui-input-d5a8fa87" class="text-sm font-medium">Email</label> <input id="ui-input-d5a8fa87" type="email" class="flex w-full rounded-md border bg-background text-foreground placeholder:text-muted-foreground transition-all focus:outline-none focus:ring-2 focus:ring-offset-1 ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 h-9 px-3 py-2 text-sm border-destructive focus:ring-destructive" aria-invalid="true" aria-describedby="ui-input-d5a8fa87-error" value="" name="signup[email]" /> <p id="ui-input-d5a8fa87-error" class="text-xs text-destructive">Email can't be blank</p> </div> <div class="flex flex-col gap-2 w-full"> <label for="ui-textarea-77d65d1b" class="text-sm font-medium">Bio</label> <textarea id="ui-textarea-77d65d1b" rows="3" class="flex w-full rounded-md border bg-background text-foreground placeholder:text-muted-foreground transition-all focus:outline-none focus:ring-2 focus:ring-offset-1 ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 px-3 py-2 text-sm resize-y border-destructive focus:ring-destructive" aria-invalid="true" aria-describedby="ui-textarea-77d65d1b-hint ui-textarea-77d65d1b-error" name="signup[bio]">Hi</textarea> <p id="ui-textarea-77d65d1b-hint" class="text-xs text-muted-foreground">A sentence or two about you.</p> <p id="ui-textarea-77d65d1b-error" class="text-xs text-destructive">Bio is too short (minimum is 20 characters)</p> </div></form>1
2
3
4
5
6
7
8
9
10
11
<%# In an app, @signup comes back from a failed save. Bound fields show its errors on their own. %><% signup = Struct.new(:email, :bio) do include ActiveModel::Validations def self.model_name = ActiveModel::Name.new(self, nil, "Signup") validates :email, presence: true validates :bio, length: { minimum: 20 } end.new("", "Hi").tap(&:validate) %><%= form_with(model: signup, url: "#", class: "flex flex-col gap-6 max-w-md") do |f| %> <%= render(UI::Input.new(form: f, field: :email, type: :email)) %> <%= render(UI::Textarea.new(form: f, field: :bio, hint: "A sentence or two about you.")) %><% end %>No notes provided.
No params configured.