Class: Storefront::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 Components::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 Components::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::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



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

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



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

def color_input
  
end

#date_inputObject



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

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

#email_inputObject



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

def email_input
  simple_input :email
end

#fax_inputObject



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

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

#money_inputObject



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

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

#number_inputObject



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

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

#numeric_inputObject



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

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

#password_inputObject



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

def password_input
  simple_input :password
end

#percent_inputObject



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

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

#phone_inputObject



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

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

#search_inputObject



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

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



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

def string_input
  simple_input :string
end

#url_inputObject



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

def url_input
  simple_input :url
end