Sha256: d121d99c856145535615a34dbaa2a69e514011ce90ba04b6375c691bc6cedc0e

Contents?: true

Size: 948 Bytes

Versions: 9

Compression:

Stored size: 948 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 = {class: 'submit'}.update(options[:wrapper_html] || {})
        template.content_tag('div', options) do
          template.content_tag('button', label, options[:input_html])
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
alchemy_cms-4.0.6 lib/alchemy/forms/builder.rb
alchemy_cms-4.0.5 lib/alchemy/forms/builder.rb
alchemy_cms-4.0.4 lib/alchemy/forms/builder.rb
alchemy_cms-4.0.3 lib/alchemy/forms/builder.rb
alchemy_cms-4.0.2 lib/alchemy/forms/builder.rb
alchemy_cms-4.0.1 lib/alchemy/forms/builder.rb
alchemy_cms-4.0.0 lib/alchemy/forms/builder.rb
alchemy_cms-4.0.0.rc2 lib/alchemy/forms/builder.rb
alchemy_cms-4.0.0.rc1 lib/alchemy/forms/builder.rb