Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kikyous/easy_form
form builder without complex dsl
https://github.com/kikyous/easy_form
Last synced: about 2 months ago
JSON representation
form builder without complex dsl
- Host: GitHub
- URL: https://github.com/kikyous/easy_form
- Owner: kikyous
- Created: 2015-05-26T09:11:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-11T08:54:23.000Z (almost 9 years ago)
- Last Synced: 2024-11-06T23:09:09.773Z (2 months ago)
- Language: Ruby
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.markdown
Awesome Lists containing this project
README
EasyForm
===
### form builder without complex dslturn
```ruby
<%= f.text_field, :title %>
```
into```ruby
<%= f.field :text_field, :title %>
```
> as you see `field` is a proxy method that send method and args to `ActionView::Helpers::FormBuilder` instance, so you can write like this: `
<%= f.field :text_area, :title %>
`output:
```html
* Title
```
template above:`app/views/easy_form/_default.html.erb`
```erb
<%= '*' if required? %> <%= label_text %>
<%= input %>
```
or you can use a named template:```ruby
<%= f.field :text_field, :title, template: 'bootstrap' %>
```
or globally:```ruby
<%= form_for @article, template: 'bootstrap' %>
```
###Install`gem 'easy_form'`
```
bundle
rails g easy_form:view
```
###More example
```erb
<%= f.field :text_area, :content %>
<%= f.field :collection_check_boxes, :category_ids, Category.all, :id, :name %>
<%= f.field :collection_check_boxes, :category_ids, Category.all, :id, :name do |b| %>
<% b.label { b.check_box } %>
<% end %><%= f.field :collection_select, :user_id, User.all, :id, :name %>
```
###Method and object in template
- input (input tag generated with rails form builder)
- field (field, such as :title)
- label_text (text display as label)
- required? (this field is required?)
- builder (rails form builder)