Sha256: d6a2a81ed599b5ae95a1bcd3fe1fee2129bcd7df027fd3a58ba285763b78033b

Contents?: true

Size: 718 Bytes

Versions: 2

Compression:

Stored size: 718 Bytes

Contents

# frozen_string_literal: true

module DynamicScaffold
  module Form
    module Item
      class SingleOption < Base
        def initialize(config, type, *args)
          name = args.shift
          html_attributes = args.extract_options!
          @args = args
          super(config, type, name, html_attributes)
        end

        def render(view, form, classnames = nil)
          html_attributes = build_html_attributes(classnames)
          # Retain the value of the password field on error.
          html_attributes[:value] = form.object.public_send(@name) if @type == :password_field
          form.public_send(@type, @name, *build_args(view, @args), html_attributes)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dynamic_scaffold-2.0.1 lib/dynamic_scaffold/form/item/single_option.rb
dynamic_scaffold-2.0.0 lib/dynamic_scaffold/form/item/single_option.rb