class Basepack::Forms::Edit

Attributes

builder_default_options[RW]
path[RW]
simple_form[R]

Public Class Methods

data_picker_options() click to toggle source
# File lib/basepack/forms/edit.rb, line 9
def data_picker_options
  {
    dateFormat:        date_format, # TODO - without %d -> dd, ...
    dayNames:          day_names,
    dayNamesShort:     abbr_day_names,
    dayNamesMin:       abbr_day_names,
    firstDay:          "1",
    monthNames:        month_names,
    monthNamesShort:   abbr_month_names,
  }
end
new(factory, chain, options = {}) click to toggle source
Calls superclass method Basepack::Forms::Base::new
# File lib/basepack/forms/edit.rb, line 29
def initialize(factory, chain, options = {})
  super
  @path = options[:path]
  @builder_default_options = {
    html:     { multipart: true, class: 'form-horizontal denser' },
    defaults: { input_html: { class: 'span6'} }
  }

  if options[:method].present?
    @builder_default_options[:method] = options[:method]
  end
end

Public Instance Methods

builder() click to toggle source
# File lib/basepack/forms/edit.rb, line 50
def builder
  simple_form
end
default_partial() click to toggle source
# File lib/basepack/forms/edit.rb, line 46
def default_partial
  'forms/edit'
end
render_field!(field) click to toggle source
# File lib/basepack/forms/edit.rb, line 155
def render_field!(field)
  if field.read_only?
    simple_form.input field.name, label: field.label, hint: field.help, required: field.required? do
      field.pretty_value
    end
  else
    view.render field.partial, form: self, field: field
  end
end
textfield_options(field) click to toggle source
# File lib/basepack/forms/edit.rb, line 141
def textfield_options(field)
  options = (field.html_attributes || {}).dup
  options.reverse_merge!(@builder_default_options[:defaults][:input_html]) if @builder_default_options[:defaults]
  options
end
with_simple_form(simple_form) { |self| ... } click to toggle source
# File lib/basepack/forms/edit.rb, line 54
def with_simple_form(simple_form, &block)
  @simple_form = simple_form
  begin
    yield(self)
  ensure
    @simple_form = nil
  end
end