Class: KirguduBase::AuthenticationFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Includes:
ActionView::Helpers::AssetTagHelper, ActionView::Helpers::TagHelper
Defined in:
app/helpers/kirgudu_base/authentication_form_builder.rb

Instance Method Summary collapse

Instance Method Details

#error_label(label, html_options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/kirgudu_base/authentication_form_builder.rb', line 12

def error_label(label, html_options = {})

	html_options.merge!(generated: "true", style: "display: block")

	html_options_add_class(html_options, "error") if @object.errors[label].present?

	errors_in_html = []

	@object.errors[label].each do |error_message|
		errors_in_html << @template.("label", error_message.capitalize.html_safe, html_options)
	end if @object.errors[label].present?

	errors_in_html.join("").html_safe
end

#label(label, html_options = {}) ⇒ Object



27
28
29
30
31
# File 'app/helpers/kirgudu_base/authentication_form_builder.rb', line 27

def label(label, html_options = {})
	@template.("label", html_options) do
		@object.class.human_attribute_name(label)
	end
end

#password_field(label, value, html_options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/helpers/kirgudu_base/authentication_form_builder.rb', line 48

def password_field(label, value, html_options = {})
	html_options ||= {}
	html_options.merge!(
		{
			id: "#{@object.class.for_form_params}_#{label}",
			name: "#{@object.class.for_form_params}[#{label}]",
			type: "password",
			value: value || @object[label]
		}
	)
	html_options_add_class(html_options, "error") if @object.errors[label].present?
	@template.("input", "", html_options)
end

#text_field(label, value, html_options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/helpers/kirgudu_base/authentication_form_builder.rb', line 34

def text_field(label, value, html_options = {})
	html_options ||= {}
	html_options.merge!(
		{
			id: "#{@object.class.for_form_params}_#{label}",
			name: "#{@object.class.for_form_params}[#{label}]",
			type: "text",
			value: value || @object[label]
		}
	)
	html_options_add_class(html_options, "error") if @object.errors[label].present?
	@template.("input", "", html_options)
end