Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

1.6 KB
Raw Blame
<%
  custom_width_form = Class.new(ApplicationForm) do
    form do |f|
      f.text_field(
        name: :ultimate_answer,
        label: "Auto",
        caption: "Takes container width",
        required: true,
        input_width: :auto
      )

      f.text_field(
        name: :hours,
        label: "hours",
        type: :number,
        required: true,
        trailing_visual: { text: { text: "min" } },
        input_width: :xsmall
      )

      f.text_field(
        name: :ultimate_answer,
        label: "Small",
        required: true,
        caption: "Small fields cannot contain a much longer caption. It will overflow until it reaches the form width.",
        input_width: :small
      )

      f.text_field(
        name: :lots_of_text,
        label: "Medium",
        required: true,
        input_width: :medium
      )

      f.select_list(
        name: "cities",
        label: "Large",
        caption: "All widths also work on Select fields",
        include_blank: true,
        required: true,
        input_width: :large
      ) do |city_list|
        city_list.option(label: "Lopez Island", value: "lopez_island")
        city_list.option(label: "Bellevue", value: "bellevue")
        city_list.option(label: "Seattle", value: "seattle")
      end

      f.text_field(
        name: :lots_of_text,
        label: "XLarge",
        required: true,
        input_width: :xlarge
      )

      f.text_field(
        name: :lots_of_text,
        label: "XXLarge",
        required: true,
        input_width: :xxlarge
      )
    end
  end
%>

<%= primer_form_with(url: "/foo") do |f| %>
  <%= render(custom_width_form.new(f)) %>
<% end %>