Class: GOVUKDesignSystemFormBuilder::Elements::Document
- Inherits:
-
Base
- Object
- Base
- GOVUKDesignSystemFormBuilder::Elements::Document
- Includes:
- FileElement
- Defined in:
- lib/govuk_design_system_formbuilder/elements/document.rb
Instance Method Summary collapse
-
#initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:, **kwargs, &block) ⇒ Document
constructor
A new instance of Document.
- #preview ⇒ Object
Methods included from FileElement
Constructor Details
#initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:, **kwargs, &block) ⇒ Document
Returns a new instance of Document.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/govuk_design_system_formbuilder/elements/document.rb', line 10 def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:, **kwargs, &block) super(builder, object_name, attribute_name, &block) @mime_types = mime_types @label = label @caption = @hint = hint @html_attributes = kwargs.merge() @form_group = form_group end |
Instance Method Details
#preview ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/govuk_design_system_formbuilder/elements/document.rb', line 22 def preview = {} add_option(, :data, "#{stimulus_controller}_target", "preview") add_option(, :class, "preview-file") add_option(, :class, "hidden") unless preview? tag.div(**) do filename = @builder.object.send(@attribute_name).filename.to_s tag.p(filename, class: "preview-filename") + destroy_element_trigger end end |