Class: Formtastic::Inputs::ListInput
Instance Method Summary
collapse
#ci_hidden_field, #ci_text_field, #icon_tag, #input_classes
Instance Method Details
#has_quantity? ⇒ Boolean
7
8
9
10
11
12
13
|
# File 'lib/formtastic/inputs/list_input.rb', line 7
def has_quantity?
if @has_quantity.nil?
@has_quantity = options[:has_quantity]
@has_quantity = true if @has_quantity.nil?
end
@has_quantity
end
|
#to_html ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/formtastic/inputs/list_input.rb', line 15
def to_html
fields = options[:fields]
values = @object ? @object.send(method) : nil
input_wrapping do
label_html <<
template.content_tag(:div, class: 'item-quantity-group') do
tags = select_html
tags << quantity_html if has_quantity?
tags << buttons(false)
end <<
template.content_tag(:div, nil, class: 'item-list-container') do
template.content_tag(:table, class: 'item-table') do
template.content_tag(:tr) do
= fields.map {|field|
= field.first[0]
template.content_tag(:th, .to_s)
}.join.html_safe
<< template.content_tag(:th, 'Quantity') if has_quantity?
<< template.content_tag(:th)
end <<
table_row <<
if values
values.map {|value| table_row(false, value)}.join.html_safe
end
end
end
end
end
|