Module: Card::Set::All::Formgroup::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
tmpsets/set/mod023-edit/all/formgroup.rb

Instance Method Summary collapse

Instance Method Details

#formgroup(title, opts = {}, &block) ⇒ Object

a formgroup has a label, an editor and help text



10
11
12
13
14
# File 'tmpsets/set/mod023-edit/all/formgroup.rb', line 10

def formgroup title, opts={}, &block
  wrap_with :div, formgroup_div_args(opts[:class]) do
    formgroup_body title, opts, &block
  end
end

#formgroup_body(title, opts, &block) ⇒ Object



16
17
18
19
20
21
# File 'tmpsets/set/mod023-edit/all/formgroup.rb', line 16

def formgroup_body title, opts, &block
  label = formgroup_label opts[:editor], title
  editor_body = editor_wrap opts[:editor], &block
  help_text = formgroup_help_text opts[:help]
  "#{label}<div>#{help_text} #{editor_body}</div>"
end

#formgroup_div_args(html_class) ⇒ Object



30
31
32
33
34
35
# File 'tmpsets/set/mod023-edit/all/formgroup.rb', line 30

def formgroup_div_args html_class
  div_args = { class: ["form-group", html_class].compact.join(" ") }
  div_args[:card_id] = card.id if card.real?
  div_args[:card_name] = h card.name if card.name.present?
  div_args
end

#formgroup_help_text(text = nil) ⇒ Object



37
38
39
40
41
42
43
# File 'tmpsets/set/mod023-edit/all/formgroup.rb', line 37

def formgroup_help_text text=nil
  return "" if text == false

  class_up "help-text", "help-block"
  voo.help = text if voo && text.to_s != "true"
  _render_help
end

#formgroup_label(editor_type, title) ⇒ Object



23
24
25
26
27
28
# File 'tmpsets/set/mod023-edit/all/formgroup.rb', line 23

def formgroup_label editor_type, title
  return if voo&.hide?(:title) || title.blank?

  label_type = editor_type || :content
  form.label label_type, title
end