Sha256: cc5be9d3b8374e15630d1c9753984aae9dbecf161df1efd33a7b17ff4974a0e4
Contents?: true
Size: 1.72 KB
Versions: 6
Compression:
Stored size: 1.72 KB
Contents
# frozen_string_literal: true module UiBibz::Ui::Core::Forms::Files # 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 # class FileField < UiBibz::Ui::Core::Component # See UiBibz::Ui::Core::Component.initialize def initialize(content = nil, options = nil, html_options = nil, &block) super end # Render html tag def pre_render content_tag :div, html_options do concat file_field_tag content, class: 'custom-file-input', multiple: options[:multiple], disabled: disabled? concat label_tag label_name, label_content, class: 'custom-file-label' end end private def label_name html_options[:id] || content end def label_content options[:value] || '' end def component_html_classes super << 'custom-file' end end end
Version data entries
6 entries across 6 versions & 1 rubygems