Class: Formatic::Wrapper

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

Overview

Instance Method Summary collapse

Methods inherited from ApplicationComponent

#initialize

Constructor Details

This class inherits a constructor from Formatic::ApplicationComponent

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/components/formatic/wrapper.rb', line 53

def error?
  error_messages.present?
end

#error_messagesObject



69
70
71
72
73
74
# File 'app/components/formatic/wrapper.rb', line 69

def error_messages
  @error_messages ||= ::Formatic::Wrappers::ErrorMessages.call(
    object:,
    attribute_name:
  )
end

#hintObject



89
90
91
92
93
94
95
96
97
98
# File 'app/components/formatic/wrapper.rb', line 89

def hint
  return manual_hint if manual_hint != true && manual_hint != false

  @hint ||= ::Formatic::Wrappers::Translate.call(
    prefix: :'helpers.hint',
    object:,
    attribute_name:,
    object_name: f&.object_name
  )
end

#hint?Boolean

Whether to display a hint or not.

Returns:

  • (Boolean)


49
50
51
# File 'app/components/formatic/wrapper.rb', line 49

def hint?
  manual_hint != false
end

#hint_before_input?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'app/components/formatic/wrapper.rb', line 65

def hint_before_input?
  manual_hint == :before_input
end

#label?Boolean

Whether to display a label or not.

Returns:

  • (Boolean)


44
45
46
# File 'app/components/formatic/wrapper.rb', line 44

def label?
  manual_label != false
end

#optional?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/components/formatic/wrapper.rb', line 61

def optional?
  !required?
end

#placeholderObject


Static I18n




80
81
82
83
84
85
86
87
# File 'app/components/formatic/wrapper.rb', line 80

def placeholder
  @placeholder ||= ::Formatic::Wrappers::Translate.call(
    prefix: :'helpers.placeholder',
    object:,
    attribute_name:,
    object_name: f&.object_name
  )
end

#required?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/components/formatic/wrapper.rb', line 57

def required?
  @required ||= ::Formatic::Wrappers::Required.call(manual_required:, object:, attribute_name:)
end

#toggle_offObject



109
110
111
112
113
114
115
116
# File 'app/components/formatic/wrapper.rb', line 109

def toggle_off
  @toggle_off ||= ::Formatic::Wrappers::Translate.call(
    prefix: :'helpers.hint',
    object:,
    attribute_name: :"#{attribute_name}_inactive",
    object_name: f&.object_name
  )
end

#toggle_onObject



100
101
102
103
104
105
106
107
# File 'app/components/formatic/wrapper.rb', line 100

def toggle_on
  @toggle_on ||= ::Formatic::Wrappers::Translate.call(
    prefix: :'helpers.hint',
    object:,
    attribute_name: :"#{attribute_name}_active",
    object_name: f&.object_name
  )
end