Menu

A form builder to style every Rails form
📰

A form builder to style every Rails form

DEV Community: webdev·Rails Designer·about 16 hours ago
#MToFo1Pc
#devtowebdev#devto#dev#attribute#enter
Long article (1600 words) — no AI summary yet.
Reading 0:00
15s threshold

Every Rails app I have started the last few years, includes the same custom form builder. I have copied this one file from app to app, it is not pretty but it keeps every input style in one place and it turns four lines of markup into one (think of it as simpler simple_form —if you know, you know—except you own the code, which I like in this case).

Add is as the default

First, look at what the form looks like when I write it. Here is a part of the settings page in the demo app .

<%= form_with model : @workspace do | form | %> <%= form . input :name %> <%= form . input :website , label_suffix : "Optional" %> <%= form . input :description , as : :text %>

<%= form . submit %> <% end %>

Enter fullscreen mode

Exit fullscreen mode

No need to add classes or wrapper divs.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.