Sha256: 20e9719c28ef7080bc6126b0d09fcede3528ca99cb12c745b2e794e5da1707d2
Contents?: true
Size: 1.51 KB
Versions: 7
Compression:
Stored size: 1.51 KB
Contents
module TaoForm module Inputs class StringInput < ::SimpleForm::Inputs::StringInput def input(wrapper_options = nil) origin_input = super template.content_tag :div, class: field_class do template.concat field_prefix template.concat origin_input template.concat field_suffix template.concat(clear_link) if search_input? end end private def field_prefix @field_prefix ||= begin prefix = search_input? ? template.tao_icon(:search) : options[:prefix] if prefix.present? @builder.label(@attribute_name, prefix, class: 'prefix') else '' end end end def field_suffix @field_suffix ||= if options[:suffix].present? @builder.label(@attribute_name, options[:suffix], class: 'suffix') else '' end end def field_class @field_class ||= begin classes = ['text-field'] classes << 'text-field-with-prefix' if field_prefix.present? classes << 'text-field-with-suffix' if field_suffix.present? classes << 'not-empty' if @builder.object.send(attribute_name).present? classes end end def clear_link @clear_link ||= template.link_to 'javascript:;', class: 'link-clear' do template.concat template.tao_icon(:close) end end def search_input? input_type == :search end end end end
Version data entries
7 entries across 7 versions & 1 rubygems