Skip to content
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

Collection option for semantic_fields_for #913

Closed
pduersteler opened this issue Jan 24, 2013 · 2 comments
Closed

Collection option for semantic_fields_for #913

pduersteler opened this issue Jan 24, 2013 · 2 comments

Comments

@pduersteler
Copy link

Let's say you have a form for @project and want to provide a form to add/edit multiple tasks at once.

f.inputs for: :tasks do |t|
  t.input :name
end

This renders all available tasks in @project. However, if you want to limit the tasks by a collection you are building (to create) or fetching (to update), – e.g. a collection of tasks you have selected previously to mass-edit – you don't have a "formtastic-native" option to define the collection.

DSL I am talking about:

f.inputs for: :tasks, collection: @my_tasks_collection do |t|
  t.input :name
end

Would that be in the proper sense of @justinfrench / formtastic? If yes, I'd go for that feature. Or is there already a solution to this (which I just haven't found)?

@digitalcora
Copy link

f.semantic_fields_for :tasks, @some_tasks works for me (just passing the collection as a second argument). This mirrors the built-in fields_for. Not sure if there is currently a way to do the same thing with inputs.

@justinfrench
Copy link
Member

@pduersteler The API you've proposed sounds pretty good. AS @Grantovich pointed out, there is a work-around. Would love to see a pull-request for your improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants