Howto set the form_id in the button_to method


#1

I have a very simple procedure that I am trying to implement.
I have the following code in my controller:

<%= text_field(:invoice, :id, :size => 20, :onkeydown =>

%Q($(‘button-id’).action = ‘#{url_for(:controller => ‘invoice’, :action
=>
‘edit’)}?id=’ + $F(‘invoice_id’);)) %>
<%= button_to (‘Goto Invoice #’, {:id => ‘invoice_id’, :action =>
:edit}, {:id => ‘button-id’}) %>

(Thanks to the help of Francois, btw).

I want to simply have the user enter and invoice # and press the button
that
will then show the selected invoice in with the edit action.
However, I need to be able to set the form id that is automatically
generated by the button_to method to use the above javascript.

Does anyone know how to do this?
Or is there an easier way to accomplish my goal here?

Thanks,
~damon


#2

Hello Damon,

2005/12/6, Damon H. removed_email_address@domain.invalid:

I want to simply have the user enter and invoice # and press the button that
will then show the selected invoice in with the edit action.
However, I need to be able to set the form id that is automatically
generated by the button_to method to use the above javascript.

Looking at the button_to macro, there is no way currently to set the
form’s ID.

Does anyone know how to do this?
Or is there an easier way to accomplish my goal here?

Just thought of something - you’re not by any chance nesting forms
too, right ? That’s disallowed.

If you are not nesting forms, then the following should work:
<%= start_form_tag :controller => ‘invoice’, :action => ‘edit’ %>
Invoice No: <%= text_field ‘invoice’, ‘id’ %>
<%= submit_tag ‘Go’ %>
<%= end_form_tag %>

That should do the trick.

DTSTTCPW (Do The Simplest Thing That Could Possibly Work)…

Bye !