Sha256: 46ea7483c2dc7b5edd2c2e518c715834ac6bf774775204623f4d5cd1e9aab06c

Contents?: true

Size: 984 Bytes

Versions: 7

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true

module PgEngine
  module FormHelper
    def pg_form_for(object, *args, &)
      if object.is_a? PgEngine::BaseDecorator
        object = object.target_object
      elsif object.is_a?(PgEngine::BaseRecord) &&
            object.decorator_class.present? &&
            object.decorator_class < PgEngine::BaseDecorator
        object = object.decorate.target_object
      end
      # byebug
      options = args.extract_options!

      options[:builder] = PgFormBuilder
      options[:html] ||= {}
      options[:html][:class] = if options[:html].key?(:class)
                                 ['pg-form', options[:html][:class]].compact
                               else
                                 'pg-form'
                               end

      simple_form_for(object, *(args << options), &)
    end

    def url_change_format(url, formato)
      uri = URI.parse(url)
      uri.path = "#{uri.path}.#{formato}"
      uri.to_s
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pg_rails-7.0.8.pre.alpha pg_engine/app/helpers/pg_engine/form_helper.rb
pg_rails-7.0.7 pg_engine/app/helpers/pg_engine/form_helper.rb
pg_rails-7.0.6 pg_engine/app/helpers/pg_engine/form_helper.rb
pg_rails-7.0.5 pg_engine/app/helpers/pg_engine/form_helper.rb
pg_rails-7.0.4 pg_engine/app/helpers/pg_engine/form_helper.rb
pg_rails-7.0.3 pg_engine/app/helpers/pg_engine/form_helper.rb
pg_rails-7.0.2 pg_engine/app/helpers/pg_engine/form_helper.rb