Sha256: 828796ce51bc9e66c6c118893ef02128f2b9319806daa8d564a5a4f31a979887

Contents?: true

Size: 698 Bytes

Versions: 2

Compression:

Stored size: 698 Bytes

Contents

require 'active_support/core_ext/string/output_safety'

class ButtonFileInput < SimpleForm::Inputs::FileInput
  attr_accessor :output_buffer

  def input(wrapper_options = nil)
    input_html_options[:class] << 'hidden inputfile'
    merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)

    (@builder.file_field(attribute_name, merged_input_options) + button).html_safe
  end

  private

  def button
    content_tag(:div) do
      content_tag(:label, for: input_class) do
        content_tag(:span, class: options[:class]) do
          label_text.present? ? label_text : I18n.t("simple_form.labels.defaults.#{attribute_name}")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_form_custom_inputs-0.0.4 lib/simple_form_custom_inputs/simple_form/button_file_input.rb
simple_form_custom_inputs-0.0.3 lib/simple_form_custom_inputs/simple_form/button_file_input.rb