Class: EacRailsUtils::CommonFormHelper::FormBuilder

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

Defined Under Namespace

Modules: CommonTextFields, CurrencyField, DateField, FieldsFor, FileField, RadioSelectField, SelectField, TimeField, YearMonthField Classes: AssociationSelectField, 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

Constructor Details

#initialize(form, helper) ⇒ FormBuilder

Returns a new instance of FormBuilder.



23
24
25
26
27
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder.rb', line 23

def initialize(form, helper)
  @form = form # rubocop:disable Rails/HelperInstanceVariable
  @helper = helper # rubocop:disable Rails/HelperInstanceVariable
  @field_errors_showed = Set.new # rubocop:disable Rails/HelperInstanceVariable
end

Instance Attribute Details

#field_errors_showedObject (readonly)

Returns the value of attribute field_errors_showed.



21
22
23
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder.rb', line 21

def field_errors_showed
  @field_errors_showed
end

#formObject (readonly)

Returns the value of attribute form.



21
22
23
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder.rb', line 21

def form
  @form
end

#helperObject (readonly)

Returns the value of attribute helper.



21
22
23
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder.rb', line 21

def helper
  @helper
end

Instance Method Details

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



29
30
31
32
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder.rb', line 29

def association_select_field(field_name, options = {})
  ::EacRailsUtils::CommonFormHelper::FormBuilder::AssociationSelectField
    .new(self, field_name, options).output
end

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



42
43
44
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder.rb', line 42

def check_box_field(field_name, options = {})
  field(field_name, options) { @form.check_box(field_name, options) } # rubocop:disable Rails/HelperInstanceVariable
end

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



46
47
48
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder.rb', line 46

def file_field(field_name, options = {})
  field(field_name, options) { @form.file_field(field_name, options) } # rubocop:disable Rails/HelperInstanceVariable
end

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



38
39
40
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder.rb', line 38

def hidden_field(field_name, options = {})
  @form.hidden_field(field_name, options) # rubocop:disable Rails/HelperInstanceVariable
end

#model_instanceObject



34
35
36
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder.rb', line 34

def model_instance
  form.object
end

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



50
51
52
53
54
55
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder.rb', line 50

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