um

Forms and settings

Form builder

Labels, hints, errors and styled controls from form_with, and a submit button that says what it's doing.

Unmagic::Components::FormBuilder is Rails' form builder with the chrome every app writes by hand: the wrapper, the label and its required marker, the hint and the error line. Its controls are styled too.

Using it

Pass it to a form, or make it the default for every form:

config.action_view.default_form_builder = Unmagic::Components::FormBuilder

Fields

<%= form_with model: @label, builder: Unmagic::Components::FormBuilder do |form| %>
  <%= form.errors_summary %>
  <%= form.field :name, "Name", required: true, hint: "Shown in the sidebar." %>
  <%= form.field :email, "Email", as: :email_field %>
  <%= form.field :role, "Role" do %>
    <%= form.select :role, Role.all %>
  <% end %>
  <%= form.submit "Add label" %>
<% end %>

field renders the label, the control (as: picks it), the hint and the attribute's errors, and marks the control aria-invalid. errors_summary shows the errors that belong to the whole record. group lays fields out in a row.

A submit that says what it's doing

form.submit "Save" reads "Saving…" while Turbo submits. Pass submitting: false to leave the label alone, or a string to choose it.

Beyond Rails' fields

switch_field, check_box_field, check_box_collection, radio_button_collection, combobox, password_field reveal: true, one_time_code_field, autogrow_text_area and uuid_field.

See it working