Sha256: 15b7513b8b33e8dd0d1e1983701a8681649204f7f445fd6bd08779a4beeac39c

Contents?: true

Size: 721 Bytes

Versions: 23

Compression:

Stored size: 721 Bytes

Contents

class Formtastic::Inputs::GridInput
  include Formtastic::Inputs::Base

  def to_html
    object = builder.object
    assets = object.send(method)

    ul = template.content_tag :ul do
      html = template.raw("")

      assets.each do |asset|
        html += template.content_tag :li do
          builder.fields_for(method, asset) do |f|
            thumbnail_html = template.image_tag f.object.asset.thumb.url
            template.link_to thumbnail_html, f.object.asset.url
          end
        end
      end

      html += template.content_tag :li do
        builder.fields_for(method, assets.build) do |f|
          f.file_field :asset
        end
      end

      html
    end

    input_wrapping { ul }
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
lalala-4.0.0.dev.58 lib/formtastic/inputs/grid_input.rb
lalala-4.0.0.dev.57 lib/formtastic/inputs/grid_input.rb
lalala-4.0.0.dev.56 lib/formtastic/inputs/grid_input.rb