GOV.UK Form Builder is suitable for use with any Rails application that uses the GOV.UK Design System.
Every component is designed to produce accessible HTML that meets all of the design system’s requirements without having to spend time reinventing the wheel.
If you’re starting from scratch, the easiest way to hit the ground running is to use the DfE’s Rails template.
Once your application is working, simply add the following line to your
Gemfile and run
Now we just need to tell Rails which form builder to use. We can do
this globally by amending the
class ApplicationController < ActionController::Base
Alternatively, if you’re not quite ready to make the full switch, you can specify the form builder on a form-by-form basis. All examples in this guide are written using Slim and ERB, but the form builder works just as well with Haml, too.
= form_for @some_object, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f|
= f.govuk_text_field :name
= f.govuk_phone_field :telephone_number
If you made it this far and everything’s working, well done!