Class: Oversee::Resources::Form
- Inherits:
-
Base
- Object
- Base
- Oversee::Resources::Form
- Includes:
- Phlex::Rails::Helpers::FormWith
- Defined in:
- app/components/oversee/resources/form.rb
Instance Method Summary collapse
-
#initialize(resource:) ⇒ Form
constructor
A new instance of Form.
- #view_template ⇒ Object
Constructor Details
#initialize(resource:) ⇒ Form
Returns a new instance of Form.
5 6 7 |
# File 'app/components/oversee/resources/form.rb', line 5 def initialize(resource:) @resource = resource end |
Instance Method Details
#view_template ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/components/oversee/resources/form.rb', line 9 def view_template div(id: dom_id(@resource)) do render Oversee::Resources::Errors.new(resource: @resource) form_with model: @resource, scope: :resource, url: helpers.create_resource_path(resource_class_name:), scope: :resource do |f| @resource.class.columns_hash.each do |key, | if [@resource.class.primary_key, "created_at", "updated_at"].include?(key) next end div(class: "py-2") do render Oversee::Field::Label.new( key: key, datatype: ..type ) div(class: "mt-2") do render Oversee::Field::Input.new( datatype: ..type, key: key ) end end end hr(class: "-mx-8 my-8") div(class: "flex justify-end mt-8") do plain f.submit "Save", class: "bg-gray-900 px-6 py-2 rounded-full text-white font-medium text-sm hover:bg-gray-700 cursor-pointer" end end end end |