Module: HakumiComponents::FormHelper

Extended by:
T::Sig
Includes:
ActionView::Helpers::FormHelper
Defined in:
app/helpers/hakumi_components/form_helper.rb

Constant Summary collapse

FormWithOptionValue =
T.type_alias do
  T.nilable(T.any(
    String,
    Symbol,
    T::Boolean,
    Numeric,
    Proc,
    ActiveModel::Model,
    T.class_of(ActionView::Helpers::FormBuilder),
    ActionView::Helpers::FormBuilder,
    T::Hash[Symbol, HakumiComponents::Types::HtmlAttributeValue]
  ))
end

Instance Method Summary collapse

Instance Method Details

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



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/helpers/hakumi_components/form_helper.rb', line 29

def hakumi_form_with(**options, &block)
  options[:builder] ||= HakumiComponents::FormBuilder

  layout = options.delete(:layout)
  if layout
    raw_html_options = options[:html]
    html_options = raw_html_options.is_a?(Hash) ? raw_html_options.dup : {}
    html_options[:class] = class_names(html_options[:class].to_s, "hakumi-form", "hakumi-form-#{layout}")
    options[:html] = html_options
  end

  form_with(**options, &block)
end