Class: Eac::CommonFormHelper::FormBuilder

Inherits:
Object
  • Object
show all
Includes:
AssociationSelectField, CommonTextFields, CurrencyField, DateField, FieldsFor, FileField, RadioSelectField, SelectField, TimeField, YearMonthField
Defined in:
lib/eac/common_form_helper/form_builder.rb,
lib/eac/common_form_helper/form_builder/date_field.rb,
lib/eac/common_form_helper/form_builder/fields_for.rb,
lib/eac/common_form_helper/form_builder/file_field.rb,
lib/eac/common_form_helper/form_builder/time_field.rb,
lib/eac/common_form_helper/form_builder/select_field.rb,
lib/eac/common_form_helper/form_builder/currency_field.rb,
lib/eac/common_form_helper/form_builder/year_month_field.rb,
lib/eac/common_form_helper/form_builder/common_text_fields.rb,
lib/eac/common_form_helper/form_builder/radio_select_field.rb,
lib/eac/common_form_helper/form_builder/association_select_field.rb,
lib/eac/common_form_helper/form_builder/searchable_association_field.rb

Defined Under Namespace

Modules: AssociationSelectField, CommonTextFields, CurrencyField, DateField, FieldsFor, FileField, RadioSelectField, SelectField, TimeField, YearMonthField Classes: SearchableAssociationField

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from YearMonthField

#year_month_field

Methods included from TimeField

#time_field

Methods included from SelectField

#select_field

Methods included from FieldsFor

#fields_for

Methods included from RadioSelectField

#radio_select_field

Methods included from DateField

#date_field

Methods included from CurrencyField

#currency_field

Methods included from AssociationSelectField

#association_select_field

Constructor Details

#initialize(form, helper) ⇒ FormBuilder

Returns a new instance of FormBuilder.



18
19
20
21
22
# File 'lib/eac/common_form_helper/form_builder.rb', line 18

def initialize(form, helper)
  @form = form
  @helper = helper
  @field_errors_showed = Set.new
end

Instance Attribute Details

#field_errors_showedObject (readonly)

Returns the value of attribute field_errors_showed.



16
17
18
# File 'lib/eac/common_form_helper/form_builder.rb', line 16

def field_errors_showed
  @field_errors_showed
end

#formObject (readonly)

Returns the value of attribute form.



16
17
18
# File 'lib/eac/common_form_helper/form_builder.rb', line 16

def form
  @form
end

#helperObject (readonly)

Returns the value of attribute helper.



16
17
18
# File 'lib/eac/common_form_helper/form_builder.rb', line 16

def helper
  @helper
end

Instance Method Details

#check_box_field(field_name, options = {}) ⇒ Object



32
33
34
# File 'lib/eac/common_form_helper/form_builder.rb', line 32

def check_box_field(field_name, options = {})
  field(field_name, options) { @form.check_box(field_name, options) }
end

#file_field(field_name, options = {}) ⇒ Object



36
37
38
# File 'lib/eac/common_form_helper/form_builder.rb', line 36

def file_field(field_name, options = {})
  field(field_name, options) { @form.file_field(field_name, options) }
end

#hidden_field(field_name, options = {}) ⇒ Object



28
29
30
# File 'lib/eac/common_form_helper/form_builder.rb', line 28

def hidden_field(field_name, options = {})
  @form.hidden_field(field_name, options)
end

#model_instanceObject



24
25
26
# File 'lib/eac/common_form_helper/form_builder.rb', line 24

def model_instance
  form.object
end

#searchable_association_field(field_name, options = {}) ⇒ Object



40
41
42
43
44
45
# File 'lib/eac/common_form_helper/form_builder.rb', line 40

def searchable_association_field(field_name, options = {})
  saf = SearchableAssociationField.new(self, field_name, options)
  saf.hidden_input <<
    field(field_name, options) { saf.visible_input } <<
    saf.javascript_tag
end