Class: Protoform::Rails::Form
- Inherits:
-
Component
- Object
- Component
- Protoform::Rails::Form
- Includes:
- Phlex::Rails::Helpers::FormAuthenticityToken, Phlex::Rails::Helpers::URLFor
- Defined in:
- lib/protoform/rails/form.rb,
lib/protoform/rails/form/field.rb
Overview
A Protos::Component class that accepts a model and sets
a Protoform::Namespace with the Object#model_name as the key and maps
the object to form fields and namespaces.
The Form::Field is a class that's meant to be extended so you can
customize the Form inputs to your applications needs. Defaults for the
input, button, label, and textarea tags are provided.
The Form component also handles Rails authenticity tokens via the
authenticity_toklen_field method and the HTTP verb via the
_method_field.
Direct Known Subclasses
Defined Under Namespace
Classes: Field
Instance Method Summary collapse
- #around_template ⇒ Object
- #assign ⇒ Object
- #collection ⇒ Object
- #field ⇒ Object
- #form_tag ⇒ Object
- #key ⇒ Object
- #namespace ⇒ Object
- #serialize ⇒ Object
- #submit(value = submit_value, **attributes) ⇒ Object
- #view_template ⇒ Object
Instance Method Details
#around_template ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/protoform/rails/form.rb', line 52 def around_template(&) form_tag do authenticity_token_field if authenticity_token? _method_field if method_field? super end end |
#assign ⇒ Object
44 45 46 |
# File 'lib/protoform/rails/form.rb', line 44 def assign(...) @namespace.assign(...) end |
#collection ⇒ Object
36 37 38 |
# File 'lib/protoform/rails/form.rb', line 36 def collection(...) @namespace.collection(...) end |
#field ⇒ Object
32 33 34 |
# File 'lib/protoform/rails/form.rb', line 32 def field(...) @namespace.field(...) end |
#form_tag ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/protoform/rails/form.rb', line 61 def form_tag(&) form( action: form_action, method: form_method, **attrs, & ) end |
#key ⇒ Object
83 84 85 |
# File 'lib/protoform/rails/form.rb', line 83 def key @model.model_name.param_key end |
#namespace ⇒ Object
40 41 42 |
# File 'lib/protoform/rails/form.rb', line 40 def namespace(...) @namespace.namespace(...) end |
#serialize ⇒ Object
48 49 50 |
# File 'lib/protoform/rails/form.rb', line 48 def serialize(...) @namespace.serialize(...) end |
#submit(value = submit_value, **attributes) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/protoform/rails/form.rb', line 74 def submit(value = submit_value, **attributes) input( **attributes, name: "commit", type: "submit", value: ) end |
#view_template ⇒ Object
70 71 72 |
# File 'lib/protoform/rails/form.rb', line 70 def view_template(&) yield_content(&) end |