Class: Katalyst::GOVUK::FormBuilder::Elements::Document
- Inherits:
-
GOVUKDesignSystemFormBuilder::Base
- Object
- GOVUKDesignSystemFormBuilder::Base
- Katalyst::GOVUK::FormBuilder::Elements::Document
- Includes:
- ActionDispatch::Routing::RouteSet::MountedHelpers, GOVUKDesignSystemFormBuilder::Traits::Error, GOVUKDesignSystemFormBuilder::Traits::HTMLAttributes, GOVUKDesignSystemFormBuilder::Traits::HTMLClasses, GOVUKDesignSystemFormBuilder::Traits::Hint, GOVUKDesignSystemFormBuilder::Traits::Label, GOVUKDesignSystemFormBuilder::Traits::Supplemental, Traits::File
- Defined in:
- lib/katalyst/govuk/form_builder/elements/document.rb
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:, **kwargs) ⇒ Document
constructor
A new instance of Document.
- #preview ⇒ Object
Constructor Details
#initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:, **kwargs) ⇒ Document
Returns a new instance of Document.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/katalyst/govuk/form_builder/elements/document.rb', line 21 def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:, **kwargs, &) super(builder, object_name, attribute_name, &) @mime_types = mime_types @label = label @caption = caption @hint = hint @html_attributes = kwargs.merge() @form_group = form_group end |
Instance Method Details
#html ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/katalyst/govuk/form_builder/elements/document.rb', line 33 def html GOVUKDesignSystemFormBuilder::Containers::FormGroup.new( *bound, **(**@form_group), ).html do safe_join([label_element, preview, hint_element, error_element, file, destroy_element, supplemental_content]) end end |
#preview ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/katalyst/govuk/form_builder/elements/document.rb', line 43 def preview = {} add_option(, :data, "#{stimulus_controller}_target", "preview") add_option(, :class, "preview-file") [: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 |