Class: Frontyard::Fields

Inherits:
ApplicationComponent show all
Defined in:
app/components/frontyard/fields.rb

Constant Summary collapse

DefaultConfig =
Config.init(
  class: "frontyard-fields"
)

Instance Method Summary collapse

Methods inherited from ApplicationComponent

#before_template, config, default_config, generate_css_class, #html_options, initialize_with, #namespace, #params, #render_model, #render_table, #view_template

Instance Method Details

#field(*args, **kwargs, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'app/components/frontyard/fields.rb', line 7

def field(*args, **kwargs, &block)
  name = args.first
  options = kwargs
  div(class: "frontyard-field") do
    label do
      plain(name.to_s.humanize)
      input(type: options[:type] || "text", name: name, **render_attributes(options))
    end
  end
end