Class: Storefront::Components::Form::String

Inherits:
Input show all
Defined in:
lib/storefront/components/form/inputs/string.rb

Overview

email attributes: autocomplete, autofocus, list, maxlength, multiple, pattern, placeholder, readonly, required, size password attributes: autocomplete, autofocus, maxlength, pattern, placeholder, readonly, required, size text, search, url, tel attributes: autocomplete, autofocus, list, maxlength, pattern, placeholder, readonly, required, size

Constant Summary

Constants included from Helpers::ContentHelper

Helpers::ContentHelper::SCOPES, Helpers::ContentHelper::SCOPES_WITH_NAMESPACE, Helpers::ContentHelper::SCOPES_WITH_NAMESPACE_AND_NESTED_MODEL, Helpers::ContentHelper::SCOPES_WITH_NESTED_MODEL

Instance Attribute Summary

Attributes inherited from Base

#options, #template

Instance Method Summary collapse

Methods inherited from Input

find, #initialize, registry, #render, resolves?

Methods inherited from Base

#initialize

Methods included from Helpers::DomHelper

#aria, #clone_attributes, #dom, #index_class, #merge_class, #merge_class!, #page, #resource_to_title, #title_widget, #title_widget_options

Methods included from Helpers::ContentHelper

#encoded_contents, #font_face_data_uri, #html5_time, #read_binary_file, #read_image_size, #rendered_text, #sanitize, #t?

Methods inherited from Base

#component_name, #extract_classes!, #extract_options!, #initialize, #inside?, #pointer, #render, #render_with_pointer, #to_s

Constructor Details

This class inherits a constructor from Storefront::Components::Form::Input

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Storefront::Components::Base

Instance Method Details

#autocomplete_inputObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/storefront/components/form/inputs/string.rb', line 63

def autocomplete_input
=begin        
  default = options[:default]
  #attribute = "#{attribute}".gsub(/_id$/, "")
  if default.present?
    name = default.name rescue ""
  else
    name = (object.send("#{attribute}".gsub(/_id$/, "")).name || "") rescue ""
  end

  options[:value] ||= default_id_for(default || object.send("#{attribute}".gsub(/_id$/, "")))
  value = User.find_by_id(options[:value])
  name = value.name if value
  value = value.id if value

  result = input(attribute, :as => :hidden, :input_html => {:class => "hidden-autocomplete", :value => value})

  options[:input_html] ||= {}
  options[:input_html].merge!(:class => "autocomplete-two", :value => name)

  result += input("#{attribute}".gsub(/_id$/, ""), options)

  result
=end        
end

#color_inputObject



59
60
61
# File 'lib/storefront/components/form/inputs/string.rb', line 59

def color_input

end

#date_inputObject



47
48
49
# File 'lib/storefront/components/form/inputs/string.rb', line 47

def date_input
  simple_input :string, :class => "date", "data-type" => "date"
end

#email_inputObject



19
20
21
# File 'lib/storefront/components/form/inputs/string.rb', line 19

def email_input
  simple_input :email
end

#fax_inputObject



43
44
45
# File 'lib/storefront/components/form/inputs/string.rb', line 43

def fax_input
  simple_input :tel, :class => "phone fax"
end

#money_inputObject



51
52
53
# File 'lib/storefront/components/form/inputs/string.rb', line 51

def money_input
  simple_input :string, :class => "money", "data-type" => "money"
end

#number_inputObject



27
28
29
# File 'lib/storefront/components/form/inputs/string.rb', line 27

def number_input
  simple_input :string, :class => "numeric", "data-type" => "numeric"
end

#numeric_inputObject



31
32
33
# File 'lib/storefront/components/form/inputs/string.rb', line 31

def numeric_input
  simple_input :string, :class => "numeric", "data-type" => "numeric"
end

#password_inputObject



15
16
17
# File 'lib/storefront/components/form/inputs/string.rb', line 15

def password_input
  simple_input :password
end

#percent_inputObject



55
56
57
# File 'lib/storefront/components/form/inputs/string.rb', line 55

def percent_input
  simple_input :string, :class => "percent", "data-type" => "percent"
end

#phone_inputObject



39
40
41
# File 'lib/storefront/components/form/inputs/string.rb', line 39

def phone_input
  simple_input :tel, :class => "phone"
end

#search_inputObject



35
36
37
# File 'lib/storefront/components/form/inputs/string.rb', line 35

def search_input
  simple_input :search, :class => "search", "data-type" => "search"
end

#string_inputObject

autofocus, pattern, placeholder, title, size, data-validate, data-validate-match, data-validate-unique



11
12
13
# File 'lib/storefront/components/form/inputs/string.rb', line 11

def string_input
  simple_input :string
end

#url_inputObject



23
24
25
# File 'lib/storefront/components/form/inputs/string.rb', line 23

def url_input
  simple_input :url
end