Skip to content

Commit

Permalink
Update documentation for forms including Arbre.
Browse files Browse the repository at this point in the history
  • Loading branch information
varyonic committed Oct 21, 2014
1 parent a031dd9 commit 774c5f0
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions docs/5-forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ a thin DSL on top of [Formtastic](https://github.com/justinfrench/formtastic):
ActiveAdmin.register Post do

form do |f|
f.inputs 'Details' do
f.input :title
f.input :published_at, label: "Publish Post At"
f.input :category
inputs 'Details' do
input :title
input :published_at, label: "Publish Post At"
li "Created at #{f.object.created_at}" unless f.object.new_record?
input :category
end
f.inputs 'Content', :body
f.actions
panel 'Markup' do
"The following can be used in the content below..."
end
inputs 'Content', :body
para "Press cancel to return to the list without saving."
actions
end

end
Expand All @@ -35,7 +40,7 @@ end

## Partials

If you require a more custom form than the DSL can provide, use a partial instead:
If you want to split a custom form into a separate partial use:

```ruby
ActiveAdmin.register Post do
Expand All @@ -45,17 +50,16 @@ end

Which looks for something like this:

```erb
<%# app/views/admin/posts/_form.html.erb %>
<%= semantic_form_for [:admin, @post] do |f| %>
<%= f.inputs :title, :body %>
<%= f.actions do %>
<%= f.action :submit %>
<li class="cancel"><%= link_to 'Cancel', collection_path %></li>
<% end %>
<% end %>
```ruby
# app/views/admin/posts/_form.html.arb
active_admin_form_for resource do |f|
inputs :title, :body
actions
end
```

This is a regular Rails partial so any template engine may be used.

## Nested Resources

You can create forms with nested models using the `has_many` method:
Expand Down

0 comments on commit 774c5f0

Please sign in to comment.