Module: ShadcnViewComponent::FormHelper

Defined in:
app/helpers/shadcn_view_component/form_helper.rb

Overview

shadcn_form_with is form_with with the shadcn builder already set, so the f.shadcn_* helpers are available without repeating builder:.

<%= shadcn_form_with model: @user do |f| %>
<%= f.shadcn_input_field :email, label: "Email", type: "email" %>
<%= f.shadcn_submit "Save" %>
<% end %>

form_with(..., builder: ShadcnViewComponent::FormBuilder) does the same thing if you would rather be explicit.

Instance Method Summary collapse

Instance Method Details

#shadcn_form_builderObject

For fields_for / form_for call sites that want the builder without the helper above.



21
22
23
# File 'app/helpers/shadcn_view_component/form_helper.rb', line 21

def shadcn_form_builder
  ShadcnViewComponent::FormBuilder
end

#shadcn_form_with(**options, &block) ⇒ Object



15
16
17
# File 'app/helpers/shadcn_view_component/form_helper.rb', line 15

def shadcn_form_with(**options, &block)
  form_with(**options.reverse_merge(builder: ShadcnViewComponent::FormBuilder), &block)
end