padrino/padrino-framework — pull request #1570 by graudeejs (2014-01-30 21:48:54+00:00)
Title: add custom index option for form_for abstract form helper

Use case:

```haml
= form_for @gallery, url_for(:galleries, :create), :method => :post do |f|
%template
= render_partial 'form_picture', :locals => { :f => f, :index => :_template_, :picture => Picture.new }
- f.object.pictures.each_with_index do |picture, i|
= render_partial 'form_picture', :locals => { :f => f, :index => i, :picture => picture }
-# ...
%button.add_nested_picture Add picture
```

```haml
.picture
= f.fields_for :pictures, picture, index: index do |ff|
.field
.label_wrap= ff.label :title
.input_wrap= ff.text_field :title
.error_wrap= ff.error_message_on :title
.clear
```

Custom index would give all sorts of flexibility for nested forms.
In example above I would write custom javascript to be able to add nested fields to form without making requests to server.

It would just copy template and append it form (in most simple case).

If you need more detailed explanation why I want this feature, let me know.