class UiBibz::Ui::Core::Forms::Files::FileField
Create a FileField
This element is an extend of UiBibz::Ui::Core::Component
.
Attributes¶ ↑
-
content
- Content of element -
options
- Options of element -
html_options
- Html Options of element
Options¶ ↑
You can add HTML attributes using the html_options
. You can pass arguments in options attribute:
-
state
- Symbol (:active
,:disabled
)
Signatures¶ ↑
UiBibz::Ui::Core::Forms::Texts::FileField.new(content, options = {}, html_options = {}).render UiBibz::Ui::Core::Forms::Texts::FileField.new(options = {}, html_options = {}) do content end.render
Examples¶ ↑
UiBibz::Ui::Core::Forms::Texts::FileField.new('upload', class: 'test') UiBibz::Ui::Core::Forms::Texts::FileField.new(class: 'test') do #content end
Helper¶ ↑
ui_file_field(options = {}, html_options = {}) do # content end
Public Instance Methods
pre_render()
click to toggle source
Render html tag
# File lib/ui_bibz/ui/core/forms/files/file_field.rb, line 47 def pre_render file_field_tag content, html_options end
Private Instance Methods
component_html_classes()
click to toggle source
Calls superclass method
UiBibz::Ui::Core::Component#component_html_classes
# File lib/ui_bibz/ui/core/forms/files/file_field.rb, line 74 def component_html_classes super << 'form-control' end
component_html_options()
click to toggle source
Calls superclass method
UiBibz::Ui::Core::Component#component_html_options
# File lib/ui_bibz/ui/core/forms/files/file_field.rb, line 53 def component_html_options super.merge({ multiple: options[:multiple], disabled: disabled?, value: format_value(options[:input_text] || options[:value]) }) end
format_value(value)
click to toggle source
# File lib/ui_bibz/ui/core/forms/files/file_field.rb, line 61 def format_value(value) case value when ActiveStorage::Attached::One return '' unless value.attached? return value.attachment.blob.filename when ActiveStorage::Attached::Many return '' end value.to_s end