Class: DeadSimpleCMS::Rails::ActionView::FormBuilders::SimpleForm

Inherits:
SimpleForm::FormBuilder
  • Object
show all
Includes:
Interface
Defined in:
lib/dead_simple_cms/rails/action_view/form_builders/simple_form.rb

Overview

Public: SimpleForm builder for use with the Dead Simple CMS The class names embed into this builder are for twitter bootstrap.

Direct Known Subclasses

SimpleFormWithBootstrap

Constant Summary collapse

AS_LOOKUP =

Public: Translation of the Attribute::Type::Base#input_type to :as option for SimpleForm.

Hash.new { |h, k| k }.update(:radio => :radio_buttons, :check_box => :boolean)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Interface

#actions, #fields_for_group, included, #preview, #radio_buttons

Class Method Details

.form_for_methodObject



16
17
18
# File 'lib/dead_simple_cms/rails/action_view/form_builders/simple_form.rb', line 16

def self.form_for_method
  :simple_form_for
end

Instance Method Details

#attribute(attribute) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dead_simple_cms/rails/action_view/form_builders/simple_form.rb', line 20

def attribute(attribute)
  as = AS_LOOKUP[attribute.input_type]
  hint = attribute.hint.to_s.dup
  hint << %{ <a href="#{attribute.value}" target="_blank">preview</a>} if attribute.is_a?(Attribute::Type::Image)
  options = {:required => attribute.required, :hint => hint, :as => as, :label => attribute.label}
  if attribute.length
    options[:input_html] = {maxlength: attribute.length}
  end
  if attribute.is_a?(Attribute::Type::CollectionSupport) && (collection = attribute.collection)
    options[:collection] = collection
    options[:include_blank] = false if as==:select
  end

  input(attribute.identifier, attribute_options.merge(options))
end

#updateObject



36
37
38
# File 'lib/dead_simple_cms/rails/action_view/form_builders/simple_form.rb', line 36

def update
  button(:submit, "Update", update_options)
end