Closed dlepage closed 13 years ago
I m not sure if that will work. In addition you are nesting form tags and that s forbidden in HTML.
I would love to have something like a data grid view, however, that s far in the future at least from my side. And I do not know how to solve that nested forms issue...
It's really wierd, it's currently working with active_scaffold 2.3 (prototype based...)
By the way, _form.erb.html doesn't contain any form tags...
only some fields and one <%= render :active_scaffold => "posts", :constraints => { :user_id => @record.id } -%>
_base_form includes form tags and _base_form is calling _form.erb.
It s a little bit irritating cause of the naming.
I would guess that apart from this nested form issue, we have as well an UJS issue. If it is working in rails 2.x, the big change to rails 3 is the change to UJS.
I'm overriding now _update_form partial... with some form_tag (with submit buttons). The user have to save each part of his form manually... Really not perfect, but It seems, this is the price to upgrade to rails 3...May be there is a better solution...
Maybe you can push a simple example app to github showing your issue (using sqlite as a backend)... ?
sure, I'll be back soon with an example app. Stay tuned ! :)
Simple example app has been created here : git@github.com:dlepage/active-scaffold-rails-3-demo-with-jquery-tabs.git
visit : http://localhost:3000/players edit a player change an email or street address (change street name) then click update... we're loosing the player context... Any ideas are welcome ! :)
At least I can tell you now the reason for your issue: in rails_jquery.js you will find the following code: $('form').live('submit.rails', function(e)
That even handler should be called if you submit a form. However, in your embedded view it is nt called. It might be a bug of jquery live event feature, however, it might be a s well a feature cause nested forms are not allowed by html.
Interesting question will be if there is a workaround...
A simple workaround would be to just override _base_form instead of _form. Just rename _form.html.erb file to _base_form.html.erb and you will not nest a form tag inside another form tag.
I ve tried it and it seems to work.
Nice ! It's working with my example. But, I have an issue in my main application because I cannot call render :super (some fields are located in some tabs...). I guess it's worked with as 2.3 because they use iframe (to embed form in form...) ? I will try to convince my client to change this screen... (big fat model... beurk,... ! :) Many thanks again for your help !
as 2.3 did not support jquery and not unobtrusive javascript.
live feature of jquery is catching events at root document and I bet they do not like a form inside of a form.. However, you might achieve the same effect if you do an explicit bind call to the form.
Basically the same problem than :
http://groups.google.com/group/activescaffold/browse_thread/thread/5fbcf418264b04b8
I tried to embed a scaffold in a form override and when I update a record in the embedded scaffold, it takes me the main page for that scaffold instead of updating inline.
After some tracing... I found the problem in the log:
Processing by Admin::PostsController#update as HTML (instead of JS)
It tried to rename _form.html.erb to _update_form.html.erb with this result :
Processing by Admin::PostsController#update as JS
But is not a solution form be, I really need to override _form.html.erb
Many thanks.