-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Tables for New/Edit Views - Editing multiple child records #1097
Comments
Curiously, both of these work: form do |f|
f.inputs "Recipe Details" do
f.input :title
f.input :owner
end
# # # # 1
table_for(recipe.ingredients) do
column :name
column :availability
end
# # # # 2
panel "Ingredients" do
table_for(recipe.ingredients) do
column :name
column :availability
end
end
end Both override the form itself, but each have their own formatting (the |
I'm looking into just how Formtastic and ActionView render these forms, and I found this to render the form at the VERY top of the page (before the ## app/admin/recipe.rb
form do |f|
# ...
custom_table(recipe.ingredients)
f.buttons
end
## /app/helpers/recipe_helper.rb
module RecipeHelper
def custom_table(stuff)
table_for ingredients, :class => "index_table", :id => "ingredients" do
column :name
column :availability
end
end
end This is a step farther since now it shows up on the same page... but I think |
I don't think that you can do that with Formtastic. You can create your own partial with Rails form helpers and render it with |
Looking at |
For now I've made this partial that does almost everything I want: https://gist.github.com/2038003 |
I'd like to request that this issue be re-opened. While (as @pcreux said) I can do what I wanted using a form partial, I really shouldn't need to--this should be an option baked into Active Admin. |
+1 |
@daxter What about opening a pull requests with an enhanced "has_many"? :) |
I would have already, but that requires "porting" it from a partial to AA itself. Once I've done that I'll be sure to send in a pull request. |
+1 |
@pcreux What should I name the feature? Should I just replace the current |
Hello @daxter Using https://github.com/nathanvda/cocoon library I was able to manipulate a nested model from within an ActiveAdmin form. With some stylesheet I could make all the inputs of the nested model to appear inlined as in your above gist, but with removal actually working. Note that I had to escape from ActiveAdmin "form" definition to a partial to output both the form and the link to the "add new" button. |
Thanks for the tip @jperville, but I figured it out a while ago. I just updated the gist with my solution starting on line 24 (sending a DELETE request to the server via jQuery) |
Hello |
Hello,
I need to be able to easily view and edit large amounts of data. This is in the from of a child model, with multiple values in each record needing to be set but each may not hold the same value necessarily (think between 5 and 30 child records). Step one in this is making the data viewable in an embedded table in the new/edit form so it takes up less space, with step two allowing in-line editing (AJAX) and batch actions as with #247.
The best way forward for step one would probably be to just render the very same table that's in the index view, but I can't figure out how to. I have a feeling this will screw around with the CSS on the page, but I can fix that when I get there.
The text was updated successfully, but these errors were encountered: