# Need some help understanding forms

**URL:** <https://www.ruby-forum.com/t/need-some-help-understanding-forms/73991>\
**Category:** Rails\
**Created:** [October 28, 2006, 9:39pm UTC](https://www.ruby-forum.com/t/need-some-help-understanding-forms/73991 "2006-10-28T21:39:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 28, 2006, 9:39pm UTC](https://www.ruby-forum.com/t/need-some-help-understanding-forms/73991/1 "2006-10-28T21:39:14Z")

</div>

im confused. all i want is data from a form to be accessible in my  
controller after the user presses a buton…

in my layout view :

\<%= start\_form\_tag(:action=\>‘search’)%\>  
\<%= text\_field(‘something1’, ‘something2’, :size =\> 25)%\>  
\<%= submit\_tag “Search”%\>

now in my controller how do i access the field in the text box?

from my reading, the first parameter is the object, second is the  
method, third are the options. how do i make it so i dont need a method,  
i just want the string in the text box?

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 28, 2006, 9:56pm UTC](https://www.ruby-forum.com/t/need-some-help-understanding-forms/73991/2 "2006-10-28T21:56:08Z")

</div>

ok so \<%= text\_field(‘search1’, ‘’, :size =\> 25)%\>

ok, so search1 is the name of the symbol that i use in params[:search1],  
and the second parameter is just what i want for a default value for  
search1 right?

please let me know if this is correct.

thanks.

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 28, 2006, 10:21pm UTC](https://www.ruby-forum.com/t/need-some-help-understanding-forms/73991/3 "2006-10-28T22:21:58Z")

</div>

Koloa,

the text\_field helper, takes a syntax such as :

text\_field(“post”, “title”, “size” =\> 20), which will build for you  
the following html.

Which when received by your controller will give you a params hash as:

params[:post][:title]

sending the above prams to a Post model,  
p = Post.new(params[:post]) will initialize the title method of p(a  
Post instantiation) with the value typed in the html form.

You should read about helpers here: [http://api.rubyonrails.com/](http://api.rubyonrails.com/)  
classes/ActionView/Helpers/FormHelper.html#M000389  
and this explanation of params should be useful: http://  
[wiki.rubyonrails.org/rails/pages/UnderstandingRequestParameters](http://wiki.rubyonrails.org/rails/pages/UnderstandingRequestParameters)

enjoy the ride koloa!

Jodi

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 29, 2006, 12:24am UTC](https://www.ruby-forum.com/t/need-some-help-understanding-forms/73991/4 "2006-10-29T00:24:14Z")

</div>

hello thank you for the explanation, i will do the reading!
