Class: Formatic::Base

Inherits:
ApplicationComponent show all
Defined in:
app/components/formatic/base.rb

Overview

All inputs inherit from this class.

Direct Known Subclasses

Checklist, Date, File, Select, Stepper, String, Textarea, Time, Toggle

Instance Method Summary collapse

Methods inherited from ApplicationComponent

#initialize

Constructor Details

This class inherits a constructor from Formatic::ApplicationComponent

Instance Method Details

#input_nameObject

# Name of the URL param for this input.



73
74
75
# File 'app/components/formatic/base.rb', line 73

def input_name
  "#{param_key}[#{attribute_name}]#{'[]' if multiple}"
end

#param_keyObject

Name of the URL param for this record.



68
69
70
# File 'app/components/formatic/base.rb', line 68

def param_key
  f.object.model_name.param_key
end

#valueObject



57
58
59
60
61
# File 'app/components/formatic/base.rb', line 57

def value
  return manual_value if manual_value != :_fetch_from_record

  f.object.public_send(attribute_name) if f.object.respond_to?(attribute_name)
end

#wrapperObject



44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/components/formatic/base.rb', line 44

def wrapper
  @wrapper ||= ::Formatic::Wrapper.new(
    f:,
    attribute_name:,
    label:,
    hint:,
    required:,
    prevent_submit_on_enter:,
    label_for_id:,
    class: wrapper_class
  )
end