https://github.com/ksylvest/formula
A Rails form generator that creates simple markup
https://github.com/ksylvest/formula
forms rails ruby
Last synced: 12 months ago
JSON representation
A Rails form generator that creates simple markup
- Host: GitHub
- URL: https://github.com/ksylvest/formula
- Owner: ksylvest
- License: mit
- Created: 2010-11-08T16:33:03.000Z (over 15 years ago)
- Default Branch: main
- Last Pushed: 2025-05-05T12:30:38.000Z (12 months ago)
- Last Synced: 2025-05-07T23:07:29.135Z (12 months ago)
- Topics: forms, rails, ruby
- Language: Ruby
- Homepage: https://formula.ksylvest.com
- Size: 689 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Formula
Formula is a Rails form helper that generates awesome markup. The project lets users create semantically beautiful forms without introducing too much syntax.
## Requirements
The gem is tested with:
- Ruby 3.3
- Rails 7.2
## Installation
```bash
gem install formula
```
## Examples
```erb
<%= formula_form_for @user do |f| %>
<%= f.input :email %>
<%= f.input :password %>
<%= f.button 'Save' %>
<% end %>
```
```erb
<%= formula_form_for @user do |f| %>
<%= f.input :email, label: "Email:", hint: "We promise never to bother you." %>
<%= f.input :password, label: "Password:", hint: "Must be at least six characters." %>
<%= f.button 'Save' %>
<% end %>
```
```erb
<%= formula_form_for @company do |f|
<%= f.input :url, container: { class: 'third' }, input: { class: 'fill' } %>
<%= f.input :phone, container: { class: 'third' }, input: { class: 'fill' } %>
<%= f.input :email, container: { class: 'third' }, input: { class: 'fill' } %>
<%= f.button 'Save', button: { class: 'fancy' } %>
<% end %>
```
```erb
<%= formula_form_for @user do |f| %>
<%= f.input :email, label: "Email:" %>
<%= f.input :password, label: "Password:" %>
<%= f.input :gender, label: 'Gender:', as: :select, choices: User::GENDERS %>
<%= formula_fields_for @user.payment do |payment_f| %>
<%= payment_f.input :credit_card_number, label: 'Number:' %>
<%= payment_f.input :credit_card_expiration, label: 'Expiration:' %>
<% end %>
<%= f.button 'Save', button: { class: 'fancy' } %>
<% end %>
```
```erb
<%= formula_form_for @user do |f| %>
<%= f.block :favourite %>
<% @favourites.each do |favourite| %>
...
<% end %>
<% end %>
<%= f.button 'Save', button: { class: 'fancy' } %>
<% end %>
```
## Copyright
Copyright (c) 2010 - 2024 Kevin Sylvestre. See LICENSE for details.