Sha256: 6150403dd4f6858370da6f89b41ea26f87cd00674f802a36d7b3ce5b33b7b5e5

Contents?: true

Size: 994 Bytes

Versions: 29

Compression:

Stored size: 994 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  module Forms
    class Builder < SimpleForm::FormBuilder
      # Renders a simple_form input, but uses input alchemy_wrapper
      #
      def input(attribute_name, options = {}, &block)
        options[:wrapper] = :alchemy

        if object.respond_to?(:attribute_fixed?) && object.attribute_fixed?(attribute_name)
          options[:disabled] = true
          options[:input_html] = options.fetch(:input_html, {}).merge(
            "data-alchemy-tooltip" => Alchemy.t(:attribute_fixed, attribute_name),
          )
        end

        super
      end

      # Renders a button tag wrapped in a div with 'submit' class.
      #
      def submit(label, options = {})
        options = {
          wrapper_html: {class: "submit"},
        }.update(options)
        template.content_tag("div", options.delete(:wrapper_html)) do
          template.content_tag("button", label, options.delete(:input_html))
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
alchemy_cms-5.1.10 lib/alchemy/forms/builder.rb
alchemy_cms-5.0.10 lib/alchemy/forms/builder.rb
alchemy_cms-5.1.9 lib/alchemy/forms/builder.rb
alchemy_cms-5.0.9 lib/alchemy/forms/builder.rb
alchemy_cms-5.1.8 lib/alchemy/forms/builder.rb
alchemy_cms-5.0.8 lib/alchemy/forms/builder.rb
alchemy_cms-5.0.7 lib/alchemy/forms/builder.rb
alchemy_cms-5.1.7 lib/alchemy/forms/builder.rb
alchemy_cms-5.1.6 lib/alchemy/forms/builder.rb
alchemy_cms-5.0.6 lib/alchemy/forms/builder.rb
alchemy_cms-5.1.5 lib/alchemy/forms/builder.rb
alchemy_cms-5.0.5 lib/alchemy/forms/builder.rb
alchemy_cms-5.1.4 lib/alchemy/forms/builder.rb
alchemy_cms-5.0.4 lib/alchemy/forms/builder.rb
alchemy_cms-5.1.3 lib/alchemy/forms/builder.rb
alchemy_cms-5.1.2 lib/alchemy/forms/builder.rb
alchemy_cms-5.1.1 lib/alchemy/forms/builder.rb
alchemy_cms-5.0.3 lib/alchemy/forms/builder.rb
alchemy_cms-5.1.0 lib/alchemy/forms/builder.rb
alchemy_cms-5.0.2 lib/alchemy/forms/builder.rb