# Form\_for not working with Markaby

**URL:** <https://www.ruby-forum.com/t/form-for-not-working-with-markaby/100991>\
**Category:** Rails\
**Created:** [August 2, 2006, 1:47pm UTC](https://www.ruby-forum.com/t/form-for-not-working-with-markaby/100991 "2006-08-02T13:47:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![larrywright](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@larrywright](https://www.ruby-forum.com/u/larrywright)\
**Post date:** [August 2, 2006, 1:47pm UTC](https://www.ruby-forum.com/t/form-for-not-working-with-markaby/100991/1 "2006-08-02T13:47:25Z")

</div>

I’m playing around with Markaby and I decided to write a little blog  
app. I’m running into issues with forms however. If I use form\_for the  
output of the form gets swallowed. For example:

form\_for :article, @article do |f|  
f.text\_field :title  
f.check\_box :published  
f.text\_area :description  
f.text\_field :pub\_date  
f.text\_area :content  
end

gets rendered as an empty form tag. The above code of course works fine  
in an rhtml file (with appropriate erb tags). Oddly form\_tag works fine  
in Markaby:

form\_tag :action =\> ‘create’  
text\_field ‘article’, ‘title’  
check\_box ‘article’, ‘published’  
text\_area ‘article’, ‘description’  
text\_field ‘article’, ‘pub\_date’  
text\_area ‘article’, ‘content’

end\_form\_tag

Renders the form just fine.

## Anyone have thoughts on why this would be? I really like Markaby, and I also prefer the form\_for syntax, so ideally I would like to use both. Any help would be appreciated.

Larry W.  
[http://www.approachingnormal.com](http://www.approachingnormal.com)  
[http://www.welcometoparenthood.com](http://www.welcometoparenthood.com)

---

<div class="post-metadata">

**Author:** ![larrywright](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@larrywright](https://www.ruby-forum.com/u/larrywright)\
**Post date:** [August 3, 2006, 12:49pm UTC](https://www.ruby-forum.com/t/form-for-not-working-with-markaby/100991/2 "2006-08-03T12:49:32Z")

</div>

try using @helpers.form\_for and see what happens. Also, you might put  
parens around the arguments just for kicks.

---

<div class="post-metadata">

**Author:** ![larrywright](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@larrywright](https://www.ruby-forum.com/u/larrywright)\
**Post date:** [August 3, 2006, 1:06pm UTC](https://www.ruby-forum.com/t/form-for-not-working-with-markaby/100991/3 "2006-08-03T13:06:35Z")

</div>

On 8/2/06, Jamie Orchard-Hays [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> try using @helpers.form\_for and see what happens. Also, you might put  
> parens around the arguments just for kicks.

No dice. I may just resort to using rhtml for my form partials and doing  
the  
rest in Markaby.

---

<div class="post-metadata">

**Author:** ![larrywright](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@larrywright](https://www.ruby-forum.com/u/larrywright)\
**Post date:** [August 3, 2006, 1:07pm UTC](https://www.ruby-forum.com/t/form-for-not-working-with-markaby/100991/4 "2006-08-03T13:07:35Z")

</div>

Perhaps there is a bug in form\_for? Or perhaps in Markaby?

---

<div class="post-metadata">

**Author:** ![larrywright](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@larrywright](https://www.ruby-forum.com/u/larrywright)\
**Post date:** [August 15, 2006, 1:01pm UTC](https://www.ruby-forum.com/t/form-for-not-working-with-markaby/100991/5 "2006-08-15T13:01:25Z")

</div>

Jamie Orchard-hays wrote:

> Perhaps there is a bug in form\_for? Or perhaps in Markaby?

You need to output the fields like this:

form\_for :article, @article do |f|  
self \<\< f.text\_field :title  
self \<\< f.check\_box :published  
self \<\< f.text\_area :description  
self \<\< f.text\_field :pub\_date  
self \<\< f.text\_area :content  
end

Alternative, you may be able to wrap the collection of fields in a div,  
but I haven’t tested that.

---

<div class="post-metadata">

**Author:** ![larrywright](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@larrywright](https://www.ruby-forum.com/u/larrywright)\
**Post date:** [January 23, 2007, 12:07am UTC](https://www.ruby-forum.com/t/form-for-not-working-with-markaby/100991/6 "2007-01-23T00:07:10Z")

</div>

Stuart R. wrote:

> The div wrapper seems to work (at least with form\_tag blocks, haven’t  
> tried form\_for though), for example:

I posted a more detailed explanation and workarounds to  
[http://code.whytheluckystiff.net/markaby/ticket/52](http://code.whytheluckystiff.net/markaby/ticket/52)

---

<div class="post-metadata">

**Author:** ![larrywright](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@larrywright](https://www.ruby-forum.com/u/larrywright)\
**Post date:** [January 20, 2007, 11:08am UTC](https://www.ruby-forum.com/t/form-for-not-working-with-markaby/100991/7 "2007-01-20T11:08:38Z")

</div>

Chris S. wrote:

> Alternative, you may be able to wrap the collection of fields in a div,  
> but I haven’t tested that.

The div wrapper seems to work (at least with form\_tag blocks, haven’t  
tried form\_for though), for example:

form\_tag({:action =\> ‘login’}, {:name =\> ‘login’}) do  
div do  
:  
:  
end  
end
