Merge pull request #72 from nick-desteffen/master

Adding complete usage documentation for simple_form
This commit is contained in:
Nathan Van der Auwera 2012-07-14 01:31:51 -07:00
commit 9b61ab50a7

View File

@ -125,11 +125,32 @@ There is an example project on github implementing it called [cocoon_formtastic_
### Using simple_form ### Using simple_form
This is almost identical to formtastic, instead of writing `semantic_fields_for` you write `simple_fields_for`. Inside our `projects/_form` partial we then write:
````haml
- simple_form_for @project do |f|
= f.input :name
= f.input :description
%h3 Tasks
#tasks
= f.simple_fields_for :tasks do |task|
= render 'task_fields', :f => task
.links
= link_to_add_association 'add task', f, :tasks
= f.submit
````
and inside the `_task_fields` partial we write:
````haml
.nested-fields
= f.input :description
= f.input :done, :as => :boolean
= link_to_remove_association "remove task", f
````
There is an example project on github implementing it called [cocoon_simple_form_demo](https://github.com/nathanvda/cocoon_simple_form_demo). There is an example project on github implementing it called [cocoon_simple_form_demo](https://github.com/nathanvda/cocoon_simple_form_demo).
### Using standard rails forms ### Using standard rails forms
I will provide a full example (and a sample project) later. I will provide a full example (and a sample project) later.