Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

EasyForm
===
### form builder without complex dsl

turn

```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)