# How does form\_for work?

**URL:** <https://discuss.rubyonrails.org/t/how-does-form-for-work/26518>\
**Category:** rubyonrails-talk\
**Created:** [March 18, 2008, 9:11pm UTC](https://discuss.rubyonrails.org/t/how-does-form-for-work/26518 "2008-03-18T21:11:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Doyle](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@Patrick\_Doyle](https://discuss.rubyonrails.org/u/Patrick_Doyle)\
**Post date:** [March 18, 2008, 9:11pm UTC](https://discuss.rubyonrails.org/t/how-does-form-for-work/26518/1 "2008-03-18T21:11:49Z")

</div>

I was just reading the documentation for "form\_for" and I noticed that it said: "Worth noting is that the form\_for tag is called in a ERb evaluation block, not an ERb output block."

Being a curious sort of guy, I wonder how this works... If it's not in an output block, how does the appropriate markup get rendered? If I wanted to figure this out myself, where would I look?

--wpd

---

<div class="post-metadata">

**Author:** ![sw0rdfish](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@sw0rdfish](https://discuss.rubyonrails.org/u/sw0rdfish)\
**Post date:** [March 18, 2008, 9:19pm UTC](https://discuss.rubyonrails.org/t/how-does-form-for-work/26518/2 "2008-03-18T21:19:45Z")

</div>

[http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M000920](http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M000920)

The reason it says that is because contrary to what would seem "normal" in rails at first glance, since the form\_for tag outputs Markup, you would put \<%= %\> around it. Since it's an Block however, it's just \<% %\> with a closing \<% end %\>

That's all the note is making you aware of.

---

<div class="post-metadata">

**Author:** ![Patrick\_Doyle](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@Patrick\_Doyle](https://discuss.rubyonrails.org/u/Patrick_Doyle)\
**Post date:** [March 19, 2008, 12:08am UTC](https://discuss.rubyonrails.org/t/how-does-form-for-work/26518/3 "2008-03-19T00:08:58Z")

</div>

Yes, I understood the note. I'm just curious... How does form\_for \_do\_ that?

--wpd

---

<div class="post-metadata">

**Author:** ![Patrick\_Doyle](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@Patrick\_Doyle](https://discuss.rubyonrails.org/u/Patrick_Doyle)\
**Post date:** [March 19, 2008, 12:47am UTC](https://discuss.rubyonrails.org/t/how-does-form-for-work/26518/4 "2008-03-19T00:47:07Z")

</div>

Oh, now I see it... form\_for calls concat(sometext, binding) which is the equivalent, through some sort of Ruby/ERb magic to \<%= sometext %\>.

OK, curiosity bump satisfied... now back to my regularly scheduled program.

--wpd
