Class: Storefront::Components::Form
- Defined in:
- lib/storefront/components/form.rb,
lib/storefront/components/form/base.rb,
lib/storefront/components/form/hint.rb,
lib/storefront/components/form/field.rb,
lib/storefront/components/form/input.rb,
lib/storefront/components/form/label.rb,
lib/storefront/components/form/errors.rb,
lib/storefront/components/form/inputs.rb,
lib/storefront/components/form/builder.rb,
lib/storefront/components/form/fieldset.rb,
lib/storefront/components/form/inputs/date.rb,
lib/storefront/components/form/inputs/file.rb,
lib/storefront/components/form/inputs/radio.rb,
lib/storefront/components/form/inputs/range.rb,
lib/storefront/components/form/inputs/value.rb,
lib/storefront/components/form/inputs/hidden.rb,
lib/storefront/components/form/inputs/select.rb,
lib/storefront/components/form/inputs/string.rb,
lib/storefront/components/form/inputs/submit.rb,
lib/storefront/components/form/inputs/checkbox.rb,
lib/storefront/components/form/inputs/textarea.rb
Defined Under Namespace
Modules: Inputs Classes: Base, Builder, Checkbox, Date, Errors, Field, Fieldset, File, Hidden, Hint, Input, Label, Radio, Range, Select, String, Submit, Textarea, Value
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 collapse
-
#access_keys ⇒ Object
readonly
Returns the value of attribute access_keys.
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#tabindex ⇒ Object
readonly
Returns the value of attribute tabindex.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(template, *args) ⇒ Form
constructor
A new instance of Form.
- #render(&block) ⇒ Object
Methods inherited from Base
#component_name, #extract_classes!, #extract_options!, #inside?, #pointer, #render_with_pointer, #to_s
Methods included from Helpers::ContentHelper
#encoded_contents, #font_face_data_uri, #html5_time, #read_binary_file, #read_image_size, #rendered_text, #sanitize, #t?
Constructor Details
#initialize(template, *args) ⇒ Form
Returns a new instance of Form.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/storefront/components/form.rb', line 7 def initialize(template, *args) = args. @template = template @model = Storefront::Model.new(:object => extract_object!(args.shift)) @attributes = extract_attributes!() @builder = Storefront::Components::Form::Builder.new( :template => template, :tabindex => 1, :access_keys => {}, :model => model ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Storefront::Components::Base
Instance Attribute Details
#access_keys ⇒ Object (readonly)
Returns the value of attribute access_keys.
4 5 6 |
# File 'lib/storefront/components/form.rb', line 4 def access_keys @access_keys end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/storefront/components/form.rb', line 4 def attributes @attributes end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/storefront/components/form.rb', line 4 def model @model end |
#tabindex ⇒ Object (readonly)
Returns the value of attribute tabindex.
4 5 6 |
# File 'lib/storefront/components/form.rb', line 4 def tabindex @tabindex end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
4 5 6 |
# File 'lib/storefront/components/form.rb', line 4 def template @template end |
Instance Method Details
#render(&block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/storefront/components/form.rb', line 20 def render(&block) template.capture_haml do template.haml_tag :form, attributes do @builder.render(&block) if block_given? unless attributes[:"data-method"] == attributes[:method] template.haml_tag :input, :type => :hidden, :name => :_method, :value => attributes[:"data-method"] end end end end |