Sha256: 0799387e3878095eb8598d2f958867ce5ec387ec275a9131a7666a42e3f4b57d

Contents?: true

Size: 1.38 KB

Versions: 128

Compression:

Stored size: 1.38 KB

Contents

---
title: '"After" content'
id: after_content
---

Primer forms is designed to be accessible by default. In service of this goal, the framework intentionally limits the types of inputs, layout styles, etc that may be used to build a form. For example, consider rendering a hidden component like a dialog or tooltip that appears when a form input is hovered or clicked. Normally these hidden elements can only be rendered _outside_ the form. The hidden elements don't "travel" with the form and can be easily forgotten.

For such cases, Primer forms feature "after" content. Like [caption templates](<%= page_path(:caption_templates) %>), after content lives in a directory named after the form, specifically in a file called after\_content.html.erb. If present, after\_content.html.erb is rendered after the last form input.

## Usage

<%= code :ruby do %>
  # app/forms/example_form.rb
  class ExampleForm < ApplicationForm
    form do |example_form|
      example_form.text_field(
        name: :name,
        label: "Name",
        id: "my-text-field"
      )
    end
  end
<% end %>

<%= code :erb do %>
  <%%# app/forms/example_form/after_content.html.erb %>
  <%%= render(
    Primer::Alpha::Tooltip.new(
      for_id: "my-text-field",
      type: :description,
      text: "Some tooltip text",
      direction: :ne
    )
  ) %>
<% end %>

## Example

<%= embed Primer::FormsPreview, :after_content_form %>

Version data entries

128 entries across 128 versions & 2 rubygems

Version Path
primer_view_components-0.30.0 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.39.1 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.39.0 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.38.0 previews/pages/forms/04_after_content.md.erb
primer_view_components-0.29.0 previews/pages/forms/04_after_content.md.erb
primer_view_components-0.28.0 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.37.1 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.37.0 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.36.2 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.36.1 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.36.0 previews/pages/forms/04_after_content.md.erb
primer_view_components-0.27.0 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.35.2 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.35.1 previews/pages/forms/04_after_content.md.erb
primer_view_components-0.26.1 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.35.0 previews/pages/forms/04_after_content.md.erb
primer_view_components-0.26.0 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.34.0 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.33.2 previews/pages/forms/04_after_content.md.erb
openproject-primer_view_components-0.33.1 previews/pages/forms/04_after_content.md.erb