Sha256: 648cb21bcd2d84d2d0aa6bd901fb90ecb22e72f2beeb0aebb13c50b55fb05e86

Contents?: true

Size: 845 Bytes

Versions: 5

Compression:

Stored size: 845 Bytes

Contents

module ExpressTemplates
  module Components
    # Provide hidden fields such as the authenticity token
    # and the utf8 enforcer tag as well as a method tag as
    # would be provided by Rails' form helpers.
    #
    # An optional method may be speficied.  Defaults to 'post'.
    class FormRailsSupport < Configurable
      emits -> (ctx) {
        div(style: 'display:none') {
          add_child helpers.utf8_enforcer_tag
          # NOTE: This should be moved into the forms module and made a FormComponent
          #       to have access to the resource_name as this code assumes existence of
          #       a resource method which may not exist
          add_child helpers.send(:method_tag, (config[:id] || ((resource.persisted? ? :put : :post) rescue :post)))
          helpers.send(:token_tag)
        }
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
express_admin-1.3.2 vendor/gems/express_templates/lib/express_templates/components/form_rails_support.rb
express_admin-1.3.1 vendor/gems/express_templates/lib/express_templates/components/form_rails_support.rb
express_templates-0.7.1 lib/express_templates/components/form_rails_support.rb
express_templates-0.7.0 lib/express_templates/components/form_rails_support.rb
express_admin-1.3.0 vendor/gems/express_templates/lib/express_templates/components/form_rails_support.rb