Get form id

Hi,

Can anyone tell me how do I get form id and print it out puts ?

Thanks

user splash wrote:

Hi,

Can anyone tell me how do I get form id and print it out puts ?

Thanks

Step 1: Rephrase your question and be more specific.
Step 2: Receive Help.
Step 3: Rejoice.

Although this may seem a bit harsh to start with, I think Phil T. is
right. user splash, please be more elaborate with your questions. The
more
detail you give us, the more likely we are to help you.

On Jan 23, 2008 7:15 AM, Phil T. [email protected]
wrote:

Step 3: Rejoice.

Posted via http://www.ruby-forum.com/.


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

hmmm still not 100% sure what you mean…does this example help?

If you had a file called register.rhtml and a model called user…

<% form_for :user do |form| %>

Screen name: <%=form.text_field :screen_name%>
<%=submit_tag "Register!", :class => "submit" %>

<% end %>

In the controller in the “register” method (I think ruby takes the
controller method name from the name of the .rhtml file) you can then
receive the form using “params[:user]” and then do @user =
User.new(params[:user]) to create a new user…

Does this help? Or am I off track?

Phil T. wrote:

hmmm still not 100% sure what you mean…does this example help?

If you had a file called register.rhtml and a model called user…

<% form_for :user do |form| %>

Screen name: <%=form.text_field :screen_name%>
<%=submit_tag "Register!", :class => "submit" %>

<% end %>

In the controller in the “register” method (I think ruby takes the
controller method name from the name of the .rhtml file) you can then
receive the form using “params[:user]” and then do @user =
User.new(params[:user]) to create a new user…

Does this help? Or am I off track?

Hmm…Sorry if my question is not clear. What I was trying to do is to
get the form’s id, and try to submit it using a link outside the form.

Example:

<% form_for :user, :url => { :action => :save_user}, :html => { :id =>
“id_of_form” } do |form| %>

Screen name: <%=form.text_field :screen_name%>
<%= end %>

<%=link_to_function “Save”, “myform.submit();” %>

I want to ask is there anyway to get id_of_form which is the form’s id ?
Correct me if any part of my code is wrong. Is it possible to submit
form with the submit link outside of the form?

Thanks

Ryan B. wrote:

Although this may seem a bit harsh to start with, I think Phil T. is
right. user splash, please be more elaborate with your questions. The
more
detail you give us, the more likely we are to help you.

On Jan 23, 2008 7:15 AM, Phil T. [email protected]
wrote:

Step 3: Rejoice.

Posted via http://www.ruby-forum.com/.

Hi,

What I want to ask is if it is possible to get the id of a form, assign
it to something like :id_of_form, then print it out using puts
params[:id_of_form]

Thanks

<%= end %>

<%=link_to_function “Save”, “myform.submit();” %>

I want to ask is there anyway to get id_of_form which is the form’s id ?
Correct me if any part of my code is wrong. Is it possible to submit
form with the submit link outside of the form?

Thanks

hmm how about:

<%=link_to “Save”, {:action => “save”, :form_id => “user”} %>

does that work?

the answer may well be yes buy you can just put an extra hidden input
tag in the form like:
<input type="hidden name=“formid” value=“1”>
and access it via params[:formid]

Adam

Adam J. wrote:

the answer may well be yes buy you can just put an extra hidden input
tag in the form like:
<input type="hidden name=“formid” value=“1”>
and access it via params[:formid]

Adam

Hi,

Just to make sure, where should I put this hidden field ? I tried
placing it in my side bar but can’t get value

Thanks

user splash wrote:

Adam J. wrote:

the answer may well be yes buy you can just put an extra hidden input
tag in the form like:
<input type="hidden name=“formid” value=“1”>
and access it via params[:formid]

Adam

Hi,

Just to make sure, where should I put this hidden field ? I tried
placing it in my side bar but can’t get value

Thanks

he’s missed a quote mark off …it should be:

note the second quote mark after hidden

<%= hidden_field_tag “name”, “value” %>

On Jan 23, 2008 8:19 PM, Adam J. [email protected] wrote:

On 23/01/2008, at 10:41 PM, Phil T. wrote:

Adam
he’s missed a quote mark off …it should be:


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

sorry also forgot to close the tag…
its:

…put this hidden field anywhere between and for
the form you want to reference