Forum: Ruby on Rails RJS replace adding multiple inputs

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.
822a498b26a2cb7d1f0f2e7e37ce61b2?d=identicon&s=25 Ed Howland (Guest)
on 2006-05-23 22:17
(Received via mailing list)
Hi,

I have a classic problem. I want to replace a hidden field inside a
form with a hidden field with some value when a link_to_remote is
pressed. In the link's action rjs, I'm doing the following:

Assume my form has the following field already

<%= hidden_field('client', 'company_id') $>

So I have a bunch of companies in a list with link_to_remote tags to
action select_company.rjs inside which I want:

page.replace "client_company_id", hidden_field("client", "company_id", :
     value => @company.id

But when I do this, it works but it adds an additional blank <input>
tag:

<input>
<input id="client_company_id", name="client[company_id]" value="4"
type="hidden">

Anyone know why?

Ed
This topic is locked and can not be replied to.