Sha256: a0dca5eb6f28a26fb558209c59568e9281eb9eb2e7e48dde952e3218608f025d

Contents?: true

Size: 1.02 KB

Versions: 23

Compression:

Stored size: 1.02 KB

Contents

format :html do
  # a formgroup has a label, an input and help text
  def formgroup title, opts={}, &block
    wrap_with :div, formgroup_div_args(opts[:class]) do
      formgroup_body title, opts, &block
    end
  end

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

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

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

  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

  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
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
card-mod-edit-0.13.4 set/all/formgroup.rb
card-mod-edit-0.13.3 set/all/formgroup.rb
card-mod-edit-0.13.2 set/all/formgroup.rb
card-mod-edit-0.13.1 set/all/formgroup.rb
card-mod-edit-0.13.0 set/all/formgroup.rb
card-mod-edit-0.11.7 set/all/formgroup.rb
card-mod-edit-0.12.0 set/all/formgroup.rb
card-mod-edit-0.11.6 set/all/formgroup.rb
card-mod-edit-0.11.5 set/all/formgroup.rb
card-mod-edit-0.11.4 set/all/formgroup.rb
card-mod-edit-0.11.3 set/all/formgroup.rb
card-mod-edit-0.11.2 set/all/formgroup.rb
card-mod-edit-0.11.1 set/all/formgroup.rb
card-mod-edit-0.11.0 set/all/formgroup.rb
card-mod-edit-0.1 set/all/formgroup.rb
card-1.100.0 mod/edit/set/all/formgroup.rb
card-1.99.6 mod/edit/set/all/formgroup.rb
card-1.99.5 mod/edit/set/all/formgroup.rb
card-1.99.4 mod/edit/set/all/formgroup.rb
card-1.99.3 mod/edit/set/all/formgroup.rb