Class: Trestle::Form::Fields::FileField
Instance Attribute Summary
#block, #builder, #name, #options, #template
Instance Method Summary
collapse
#defaults, #errors, #form_group, #initialize, #normalize_options!, #readonly?, #render
Instance Method Details
#browse_text ⇒ Object
24
25
26
|
# File 'lib/trestle/form/fields/file_field.rb', line 24
def browse_text
I18n.t("trestle.file.browse", default: "Browse")
end
|
#choose_file_text ⇒ Object
20
21
22
|
# File 'lib/trestle/form/fields/file_field.rb', line 20
def choose_file_text
I18n.t("trestle.file.choose_file", default: "Choose file")
end
|
#custom? ⇒ Boolean
16
17
18
|
# File 'lib/trestle/form/fields/file_field.rb', line 16
def custom?
options[:custom] != false
end
|
#field ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/trestle/form/fields/file_field.rb', line 5
def field
if custom?
content_tag(:div, class: "custom-file") do
concat builder.raw_file_field(name, options.merge(class: "custom-file-input"))
concat builder.label(name, choose_file_text, class: "custom-file-label", data: { browse: browse_text })
end
else
builder.raw_file_field(name, options)
end
end
|