Class: CitizenBudgetModel::CitizenBudgetFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
app/controllers/citizen_budget_model_controller.rb

Instance Method Summary collapse

Instance Method Details

#buttons(options = {}) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'app/controllers/citizen_budget_model_controller.rb', line 100

def buttons(options = {})
  @template.concat(submit)

  if block_given?
    yield
  end

  if object.persisted?
    @template.concat(@template.link_to(options.fetch(:context, object), class: 'btn btn-danger pull-right', method: :delete, data: {confirm: _('Are you sure?')}) do
      @template.(:span, nil, class: 'glyphicon glyphicon-trash') + ' ' + _('Delete')
    end)
  end

  nil
end

#check_box(method, options = {}, checked_value = '1', unchecked_value = '0') ⇒ Object



88
89
90
91
92
93
94
# File 'app/controllers/citizen_budget_model_controller.rb', line 88

def check_box(method, options = {}, checked_value = '1', unchecked_value = '0')
  return unless @template.visible?(object, method)

  content = @template.(:label, super(method, options, checked_value, unchecked_value) + ' ' + object.class.human_attribute_name(method))

  @template.(:div, content, class: 'checkbox')
end

#email_field(method, options = {}) ⇒ Object



72
73
74
# File 'app/controllers/citizen_budget_model_controller.rb', line 72

def email_field(method, options = {})
  wrapper_and_label(method, super(method, default_options(options)))
end

#errorsObject



45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/citizen_budget_model_controller.rb', line 45

def errors
  if object.errors.any?
    content = ActiveSupport::SafeBuffer.new

    object.errors.full_messages.each do |message|
      content << @template.(:li, message)
    end

    @template.(:div, @template.(:ul, content), class: 'alert alert-danger')
  end
end

#number_field(method, options = {}) ⇒ Object



76
77
78
# File 'app/controllers/citizen_budget_model_controller.rb', line 76

def number_field(method, options = {})
  wrapper_and_label(method, super(method, default_options(options)))
end

#password_field(method, options = {}) ⇒ Object



80
81
82
# File 'app/controllers/citizen_budget_model_controller.rb', line 80

def password_field(method, options = {})
  wrapper_and_label(method, super(method, default_options(options)))
end

#select(method, choices = nil, options = {}, html_options = {}) ⇒ Object



84
85
86
# File 'app/controllers/citizen_budget_model_controller.rb', line 84

def select(method, choices = nil, options = {}, html_options = {})
  wrapper_and_label(method, super(method, choices, options, default_options(options)))
end

#submitObject



96
97
98
# File 'app/controllers/citizen_budget_model_controller.rb', line 96

def submit
  button(_('Save'), class: 'btn btn-primary')
end

#text_field(method, options = {}) ⇒ Object



68
69
70
# File 'app/controllers/citizen_budget_model_controller.rb', line 68

def text_field(method, options = {})
  wrapper_and_label(method, super(method, default_options(options)))
end

#text_field_without_labelObject



65
# File 'app/controllers/citizen_budget_model_controller.rb', line 65

alias_method :text_field_without_label, :text_field

#translated_text_area(method, options = {}) ⇒ Object



61
62
63
# File 'app/controllers/citizen_budget_model_controller.rb', line 61

def translated_text_area(method, options = {})
  translated(:text_area_without_label, method, options)
end

#translated_text_field(method, options = {}) ⇒ Object



57
58
59
# File 'app/controllers/citizen_budget_model_controller.rb', line 57

def translated_text_field(method, options = {})
  translated(:text_field_without_label, method, options)
end