Form_remote_tag breaks inside table

i guess its better form to keep form tags outside of table tags anyways,
but it took a lot of trial and error to figure out thats why @params
were no longer showing up after switching form_tag to form_remote_tag.
not sure if this is a prototype ‘bug’ or ‘feature’ or what. but my next
step was to switch to a seperate form tag for each row to reduce
needless bandwidth/db usage but that isnt possible due to this
behavior… i guess i will spend another few weeks figuring out if it
will ever be posible to get distinct divs to truly line up their nested
subelements like table cells do…

carmen wrote:

i guess its better form to keep form tags outside of table tags anyways,
but it took a lot of trial and error to figure out thats why @params
were no longer showing up after switching form_tag to form_remote_tag.
not sure if this is a prototype ‘bug’ or ‘feature’ or what. but my next
step was to switch to a seperate form tag for each row to reduce
needless bandwidth/db usage but that isnt possible due to this
behavior… i guess i will spend another few weeks figuring out if it
will ever be posible to get distinct divs to truly line up their nested
subelements like table cells do…

Has anyone looked into this? I assume it has to do with tag parsing.

The following code works:

		<div id="search-tab">
			<%= form_remote_tag :update => 'search-results',
					:url => { :action => 'search', :controller => 'home' },
					:loading => "Element.show('activity')",
		    		:complete => "Element.hide('activity'); 

Element.show(‘search-box’); new Effect.SlideDown(‘search-box’)" %>







<%= image_tag ‘activity-black.gif’, :id => ‘activity’, :style
=> ‘display:none’ %>
<%= text_field_tag ‘term’ %> <%= image_submit_tag ‘/images/search3.gif’ %>

<%= end_form_tag %>

But if you put the tags within the table like the
following:

		<table>
		<div id="search-tab">
			<%= form_remote_tag :update => 'search-results',
					:url => { :action => 'search', :controller => 'home' },
					:loading => "Element.show('activity')",
		    		:complete => "Element.hide('activity'); 

Element.show(‘search-box’); new Effect.SlideDown(‘search-box’)" %>


<%= image_tag ‘activity-black.gif’, :id => ‘activity’, :style
=> ‘display:none’ %>
<%= text_field_tag ‘term’ %>
<%= image_submit_tag ‘/images/search3.gif’ %>

<%= end_form_tag %>

…then params is never set. Putting the form tags within the table is a
bad habit I picked that probably doesn’t conform to any DOM standards,
but it used to fix a weird browser bug that inserted a linebreak after
the closing form tags. Ugly HTML or not, I think that the latter should
probably work or else there should be a note in the documentation to
make your forms DOM compliant if that’s a problem. I’m glad I ran across
the original poster’s message or this behavior would have puzzled me for
a lot longer than it did.

-Pawel

Pawel S. wrote:

  			<tr>
  				<td><%= image_tag 'activity-black.gif', :id => 'activity', :style 

=> ‘display:none’ %>

<%= text_field_tag ‘term’ %>
<%= image_submit_tag ‘/images/search3.gif’ %>

<%= end_form_tag %>

…then params is never set.

Instead of using form_remote_tag and a normal submit button, try using
submit_to_remote with option :submit => ‘search_tab’


We develop, watch us RoR, in numbers too big to ignore.

Pawel S. wrote:

  	<div id="search-tab">
  		<%= form_remote_tag :update => 'search-results',
  				:url => { :action => 'search', :controller => 'home' },

Sorry for the horrible indentation, folks!

-Pawel

Matt S. wrote:

How do I go about sending multiple form values with the :submit option?
It appears you can only send one field through that way. Any thoughts?

No, all named fields within the div specified in the :submit option
will be sent.


We develop, watch us RoR, in numbers too big to ignore.

On 1/17/06, Mark Reginald J. [email protected] wrote:

Pawel S. wrote:

Instead of using form_remote_tag and a normal submit button, try using
submit_to_remote with option :submit => ‘search_tab’

How do I go about sending multiple form values with the :submit option?
It
appears you can only send one field through that way. Any thoughts?

Thanks!

Could you provide an example? I am trying to do this:

<p><div id="participants_list">
     <%= render :action => 'list_participants' %>
    </div>
        Email: <%= text_field 'participant', 'email', :size => 20,

:maxlength => 255 %>
Name: <%= text_field ‘participant’, ‘name’, :size => 20,
:maxlength => 255 %>


<%= submit_to_remote( “add_part_button”, “add”,
{:update => “participants_list”,
:url => { :action => :add_participant
},
:submit => [“participant_email”,
“participant_name”]
}) %>

Which results in:

<p><div

id=“participants_list”>

    </div>
	    Email: <input

id=“participant_email” maxlength=“255” name=
“participant[email]” size=“20” type=“text” />

	    Name: <input id="participant_name"

maxlength=“255” name=“participant[name]”
size=“20” type=“text” />
<
br/>

I also tried:

<p><div id="participants_list">
     <%= render :action => 'list_participants' %>
    </div>
        Email: <%= text_field 'participant', 'email', :size => 20,

:maxlength => 255 %>
Name: <%= text_field ‘participant’, ‘name’, :size => 20,
:maxlength => 255 %>


<%= submit_to_remote( “add_part_button”, “add”,
{:update => “participants_list”,
:url => { :action => :add_participant
},
:submit => “participant_email”
}) %>

Which gets me the participant_email element in the controller. So, I
know
how to get one value, but not two… On a side note, this works fine
from a
rails perspective, but Firefox (1.5 +) seems to crash whenever I make
that
submit… anyone else see this?

  • Matt

So, I reread your response, slapped my self in the head, and tried
submitting by the div id. It works, except that it still crashes
Firefox…
any ideas on that?

Thank you very much!

  • Matt

On 2/3/06, Matt S. [email protected] wrote:

Could you provide an example? I am trying to do this:

Which gets me the participant_email element in the controller. So, I
know

That took care of it. Thanks!

Matt S. wrote:

So, I reread your response, slapped my self in the head, and tried
submitting by the div id. It works, except that it still crashes
Firefox… any ideas on that?

Try updating Prototype using “rake update_javascripts”, and ensure
you don’t have overlaping divs and other block elements. If Firefox
is still crashing, post your final code.


We develop, watch us RoR, in numbers too big to ignore.