Sha256: 5b20fbd819b3a43a70cc8bcb390b26be0485d1cbc5c5b8cd33c5d55ba0ac77b7
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
module ExpressTemplates module Components module Forms class ExpressForm < Configurable include ExpressTemplates::Components::Capabilities::Resourceful tag :form has_option :method, 'The form method', default: 'POST', attribute: true #, options: ['PUT', 'POST', 'GET', 'DELETE'] has_option :action, 'The form action containing the resource path or url.' contains -> (&block) { div(style: 'display:none') { add_child helpers.utf8_enforcer_tag add_child helpers.send(:method_tag, resource.persisted? ? :put : :post) helpers.send(:token_tag) } block.call(self) if block } before_build -> { set_attribute(:id, form_id) set_attribute(:action, form_action) add_class(config[:id]) } def form_id [config[:id], resource.try(:id)].compact.join('_') end def form_action config[:action] || (resource.try(:persisted?) ? resource_path(ivar: true) : collection_path) end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems