Forum: Ruby on Rails form_remote_tag breaks inside table

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6f7c877de704c7cc03c8a3b2dc52df92?d=identicon&s=25 Carmen --- (carmen)
on 2006-01-13 06:21
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...
501dac4c25141b9ecffecf6819fe086b?d=identicon&s=25 Pawel Szymczykowski (makenai)
on 2006-01-18 02:27
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')" %>
				<table>
					<tr>
						<td><%= image_tag 'activity-black.gif', :id => 'activity', :style
=> 'display:none' %></td>
						<td><%= text_field_tag 'term' %></td>
						<td><%= image_submit_tag '/images/search3.gif' %></td>
					</tr>
				</table>
				<%= end_form_tag %>
			</div>

But if you put the <form></form> 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')" %>
					<tr>
						<td><%= image_tag 'activity-black.gif', :id => 'activity', :style
=> 'display:none' %></td>
						<td><%= text_field_tag 'term' %></td>
						<td><%= image_submit_tag '/images/search3.gif' %></td>
					</tr>
				<%= end_form_tag %>
                                </table>
			</div>

..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
501dac4c25141b9ecffecf6819fe086b?d=identicon&s=25 Pawel Szymczykowski (makenai)
on 2006-01-18 02:28
Pawel Szymczykowski wrote:
> 			<div id="search-tab">
> 				<%= form_remote_tag :update => 'search-results',
> 						:url => { :action => 'search', :controller => 'home' },

Sorry for the horrible indentation, folks!

-Pawel
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2006-01-18 03:04
(Received via mailing list)
Pawel Szymczykowski wrote:

> 					<tr>
> 						<td><%= image_tag 'activity-black.gif', :id => 'activity', :style
> => 'display:none' %></td>
> 						<td><%= text_field_tag 'term' %></td>
> 						<td><%= image_submit_tag '/images/search3.gif' %></td>
> 					</tr>
> 				<%= end_form_tag %>
>                                 </table>
> 			</div>
>
> ..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.
7b829a0c4495eb471379bcc786307a95?d=identicon&s=25 Matt Secoske (Guest)
on 2006-02-02 18:04
(Received via mailing list)
On 1/17/06, Mark Reginald James <mrj@bigpond.net.au> wrote:
>
> Pawel Szymczykowski 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!
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2006-02-03 03:59
(Received via mailing list)
Matt Secoske 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.
7b829a0c4495eb471379bcc786307a95?d=identicon&s=25 Matt Secoske (Guest)
on 2006-02-03 14:38
(Received via mailing list)
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 %>
            <br/>
            <%= submit_to_remote( "add_part_button", "add",
                                  {:update => "participants_list",
                                   :url => { :action => :add_participant
},
                                   :submit => ["participant_email",
"participant_name"]
                                   }) %>
    </p>


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/>
		    <input name="add_part_button"
onclick="new Ajax.Updater('participants_list',
'/main/add_participant', {asynchronous:true, evalScripts:true,
parameters:Form.serialize(document.getElementById('participant_emailparticipant_name'))});
return false;"
type="button" value="add"
/>
	</p>

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 %>
            <br/>
            <%= submit_to_remote( "add_part_button", "add",
                                  {:update => "participants_list",
                                   :url => { :action => :add_participant
},
                                   :submit => "participant_email"
                                   }) %>
    </p>

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
7b829a0c4495eb471379bcc786307a95?d=identicon&s=25 Matt Secoske (Guest)
on 2006-02-03 17:16
(Received via mailing list)
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 Secoske <secoskem@gmail.com> 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
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2006-02-03 18:34
(Received via mailing list)
Matt Secoske 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.
7b829a0c4495eb471379bcc786307a95?d=identicon&s=25 Matt Secoske (Guest)
on 2006-02-03 20:26
(Received via mailing list)
That took care of it.  Thanks!
This topic is locked and can not be replied to.