Class: Frontyard::Field
- Inherits:
-
ApplicationComponent
- Object
- Phlex::HTML
- ApplicationComponent
- Frontyard::Field
- Includes:
- Phlex::Rails::Helpers::CheckBox, Phlex::Rails::Helpers::DateSelect, Phlex::Rails::Helpers::FormWith, Phlex::Rails::Helpers::Label, Phlex::Rails::Helpers::NumberField, Phlex::Rails::Helpers::OptionsForSelect, Phlex::Rails::Helpers::Pluralize, Phlex::Rails::Helpers::Select, Phlex::Rails::Helpers::TextField
- Defined in:
- app/components/frontyard/field.rb
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
Instance Method Details
#view_template(&block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/components/frontyard/field.rb', line 15 def view_template(&block) div(**self.class.config) do # Use basic HTML label to avoid Rails helper conflicts tag(:label) { [:label] || attribute.to_s.humanize } case field_type when :text input(type: "text", name: object_attribute, **) when :number input(type: "number", name: object_attribute, **) when :date input(type: "date", name: object_attribute, **) when :checkbox input(type: "checkbox", name: object_attribute, **) else input(type: "text", name: object_attribute, **) end yield if block_given? end end |