Hello all
I'm building a form that is not based on a model. The action I want
to happen when I click submit is defined in my controller.
Here's the form code in the html.erb
<% form_tag '/gevents/dotheformstuff/' do -%>
<div>Username: <%= text_field_tag("username", "", :size => 40) %></
<div>Password: <%= password_field_tag("password", "", :size => 40) %></
<div><%= submit_tag 'Find' %></div>
<% end -%>
Is this the best way to proceed, with now me editing my routes file so
that /gevents/dotheformstuff/ get's thrown to a controller and action
of my choosing?
I've been reading about using the form_tag like this
<%= form_tag :action => "create" %>
But my rails is not liking the end_form_tag when I use that. This
might be pre rails 2 code, can someone verify?
It does seem a lot neater to describe the action in the form_tag
rather than edit routes.rb though.
Also, when I do send the data back to the controller, how do I go
about extracting it? I'm not sure of the syntax needed.
Any advice, greatly appreciated.
Hello all
I've been reading about using the form_tag like this
<%= form_tag :action => "create" %>
But my rails is not liking the end_form_tag when I use that. This
might be pre rails 2 code, can someone verify?
That is indeed pre rails 2 (and deprecated in 1.2)
It does seem a lot neater to describe the action in the form_tag
rather than edit routes.rb though.
You're conflating to things. What's deprecated is end_form_tag (ie the
non block form of form_tag). You can of course do
<% form_tag :action => "create" do %>
...
<% end %>
Also, when I do send the data back to the controller, how do I go
about extracting it? I'm not sure of the syntax needed.
It just in your params hash.
Fred
> It does seem a lot neater to describe the action in the form_tag
> rather than edit routes.rb though.
You're conflating to things. What's deprecated is end_form_tag (ie the
non block form of form_tag). You can of course do
Ack, brain still asleep. That should of course say "conflating two
things"
Frederick, thanks for clearing that up.
It's a bit tricky out there at them moment with so many sites showing
help on rails prior to 2.
We'll get there though

Thanks again.
Frederick, I'm having a doozy of a time finding out how to create a
parameters hash out of those two fields when I'm using form_tag
You couldn't point me in the right direction anyone?
Rails 2, Creating a Parameters Hash in a form using form_tag.
Can't find anything easy enough for my diseased brain
I'm not sure I understand the problem. You will get the params hash in your controller without having to do anything.
Fred
I'm not sure how to access the params hash in the controller as I
don't know how to refer to it.
Here's the form in the view
<% form_tag :action => "getcals" -%>
<div>Username: <%= text_field_tag("username", "", :size => 40) %></
<div>Password: <%= password_field_tag("password", "", :size => 40) %></
<div><%= submit_tag 'getcals' %></div>
<% end -%>
How would I refer to the params hash of that in the controller
getcals?
Thanks for helping Frederick
woops, missed a do
<% form_tag :action => "getcals" do -%>
<div>Username: <%= text_field_tag("username", "", :size => 40) %></
<div>Password: <%= password_field_tag("password", "", :size => 40) %></
<div><%= submit_tag 'getcals' %></div>
<% end -%>
Frederick, I promise you it's me who is confused, not yourself.
Thanks mate, that's worked a treat.
I can now pass these variables back and forth and do what I want.
Thanks again.