Sha256: 95369226030ef2e0a9ed5b299ecb1f2645594e2219e4000fbd4315471875afc5

Contents?: true

Size: 917 Bytes

Versions: 12

Compression:

Stored size: 917 Bytes

Contents

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

12 entries across 12 versions & 1 rubygems

Version Path
alchemy_cms-3.6.7 lib/alchemy/forms/builder.rb
alchemy_cms-3.6.6 lib/alchemy/forms/builder.rb
alchemy_cms-3.6.5 lib/alchemy/forms/builder.rb
alchemy_cms-3.6.4 lib/alchemy/forms/builder.rb
alchemy_cms-3.6.3 lib/alchemy/forms/builder.rb
alchemy_cms-3.6.2 lib/alchemy/forms/builder.rb
alchemy_cms-3.6.1 lib/alchemy/forms/builder.rb
alchemy_cms-4.0.0.beta lib/alchemy/forms/builder.rb
alchemy_cms-3.6.0 lib/alchemy/forms/builder.rb
alchemy_cms-3.5.0 lib/alchemy/forms/builder.rb
alchemy_cms-3.5.0.rc2 lib/alchemy/forms/builder.rb
alchemy_cms-3.5.0.rc1 lib/alchemy/forms/builder.rb