Class: ComfortableMexicanSofa::Content::Tag::Files
- Inherits:
-
File
- Object
- ComfortableMexicanSofa::Content::Tag
- Fragment
- File
- ComfortableMexicanSofa::Content::Tag::Files
- Defined in:
- lib/comfortable_mexican_sofa/content/tags/files.rb
Overview
Same tag as File, only it handles multiple attachments. Generally not a bad idea to handle rendering of this in a partial/helper. Example tag:
{{ cms:files identifier }}
Instance Attribute Summary
Attributes inherited from File
Attributes inherited from Fragment
#identifier, #namespace, #options, #renderable
Attributes inherited from ComfortableMexicanSofa::Content::Tag
Instance Method Summary collapse
- #content ⇒ Object
- #form_field(object_name, view, index) {|view.safe_join([input, attachments_partial], "")| ... } ⇒ Object
Methods inherited from File
Methods inherited from Fragment
#form_field_id, #fragment, #initialize, #render
Methods inherited from ComfortableMexicanSofa::Content::Tag
#allow_erb?, #initialize, #nodes, #render
Constructor Details
This class inherits a constructor from ComfortableMexicanSofa::Content::Tag::File
Instance Method Details
#content ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/comfortable_mexican_sofa/content/tags/files.rb', line 10 def content return "" if fragment..blank? fragment..collect do || super(file: , label: .filename) end.join(" ") end |
#form_field(object_name, view, index) {|view.safe_join([input, attachments_partial], "")| ... } ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/comfortable_mexican_sofa/content/tags/files.rb', line 18 def form_field(object_name, view, index) name = "#{object_name}[fragments_attributes][#{index}][files][]" input = view.send(:file_field_tag, name, id: form_field_id, multiple: true, class: "form-control") = if fragment. view.render( partial: "comfy/admin/cms/fragments/form_fragment_attachments", locals: { object_name: object_name, index: index, attachments: fragment., fragment_id: identifier, multiple: true } ) end yield view.safe_join([input, ], "") end |