Module: Formular::Element::Modules::Wrapped::InstanceMethods

Defined in:
lib/formular/element/modules/wrapped.rb

Instance Method Summary collapse

Instance Method Details

#errorObject



47
48
49
50
51
52
# File 'lib/formular/element/modules/wrapped.rb', line 47

def error
  return '' unless has_errors?

  error_options[:content] = error_text
  builder.error(error_options).to_s
end

#hintObject



54
55
56
57
58
59
60
# File 'lib/formular/element/modules/wrapped.rb', line 54

def hint
  return '' unless has_hint?
  hint_opts = hint_options.dup
  hint_opts[:content] = hint_text
  hint_opts[:id] = hint_id # FIXME: this should work like a standard set_default
  builder.hint(hint_opts).to_s
end

#labelObject



38
39
40
41
42
43
44
45
# File 'lib/formular/element/modules/wrapped.rb', line 38

def label
  return '' unless has_label?

  label_opts = label_options.dup
  label_opts[:content] = label_text
  label_opts[:labeled_control] = self
  builder.label(label_opts).to_s
end

#wrapper(&block) ⇒ Object



33
34
35
36
# File 'lib/formular/element/modules/wrapped.rb', line 33

def wrapper(&block)
  wrapper_element = has_errors? ? :error_wrapper : :wrapper
  builder.send(wrapper_element, wrapper_options, &block)
end