A really simple form builder targeting the newest versions of Rails and Spectre.css.
Requirements
- Rails (> 5.0, < 8.0)
- Spectre.css (0.5.0)
This gem is currently under development and hasn't reached a stable version yet, however there are tests for every basic field input so far! The current test suite is written with MiniTest.
Use rake
to run tests.
$ rake
Add this line to your application's Gemfile:
gem 'spectre_form_with', github: 'cimon-io/spectre_form_with'
And then execute:
$ bundle
Or install it yourself as:
$ gem install spectre_form_with
An example registration form:
<%= spectre_form_with model: @user, url: users_path do |f| %>
<%= f.error_notification %>
<%= f.group :email do %>
<%= f.label :email %>
<%= f.email_field :email %>
<%= f.errors :email %>
<% end %>
<%= f.submit 'Sign up', class: 'btn btn-primary' %>
<% end %>
Will produce the following HTML:
<form id="new_user" action="/users" accept-charset="UTF-8" data-remote="true" method="post"><input name="utf8" type="hidden" value="✓"><input type="hidden" name="authenticity_token" value="0adYsLm0u0YNunSUK5a4i/OLe73e1qRYO0u4mMDL5/1x1CqZDXNurGrpbRUm2EjmFzq4EMVIUjE2MNPhaxxCog==">
<div class="form-group">
<label class="form-label" for="user_email">Email</label>
<input class="form-input" type="email" name="user[email]">
</div>
<input type="submit" name="commit" value="Sign up" class="btn btn-primary" data-disable-with="Sign up">
</form>