New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom index option for form_for abstract form helper #1570

Merged
merged 1 commit into from Jan 31, 2014

Conversation

Projects
None yet
2 participants
@graudeejs
Contributor

graudeejs commented Jan 30, 2014

Use case:

= 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
.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.

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Jan 31, 2014

Member

Thanks, I had similar problems.

Member

ujifgc commented Jan 31, 2014

Thanks, I had similar problems.

ujifgc added a commit that referenced this pull request Jan 31, 2014

Merge pull request #1570 from graudeejs/form_for_index
add custom index option for form_for abstract form helper

@ujifgc ujifgc merged commit bd84d36 into padrino:master Jan 31, 2014

1 check failed

default The Travis CI build failed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment