# Css\_fields\_for in CSSFormBuilder

**URL:** <https://www.ruby-forum.com/t/css-fields-for-in-cssformbuilder/87427>\
**Category:** Rails\
**Created:** [March 2, 2007, 3:44pm UTC](https://www.ruby-forum.com/t/css-fields-for-in-cssformbuilder/87427 "2007-03-02T15:44:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![redbaritone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/779978/32.png) [@redbaritone](https://www.ruby-forum.com/u/redbaritone)\
**Post date:** [March 2, 2007, 3:44pm UTC](https://www.ruby-forum.com/t/css-fields-for-in-cssformbuilder/87427/1 "2007-03-02T15:44:31Z")

</div>

Trying to use CSSFormBuilder, but having a problem with its  
css\_fields\_for wrapper. When I check out the code, there’s a fairly  
important-looking line commented out. Is anyone using this? Is that  
method broken, or have I just not figured it out, yet? If you aren’t  
using this, what other good form builders are there?

Here’s what I have:

\<%= error\_messages\_for ‘customer’ %\>

\<% fieldset\_tag ‘General Data’ do %\>  
\<%= @f.text\_field :name, :class=\>‘double-size’ %\>  
\<%= @f.text\_field :ein, :class=\>‘normal-size’ %\>  
  
  
\<%= @f.text\_field :product, :class=\>‘double-size’ %\>  
  
  
\<% end %\>  
\<%= error\_messages\_for ‘address’%\>  
\<% fieldset\_tag ‘Address’ do %\>  
\<% css\_fields\_for :address, do |addr| %\>  
\<%= addr.text\_field :street, :class=\>‘normal-size’ %\>  
  
  
\<%= addr.text\_field :city, :class=\>‘normal-size’ %\>  
  
  
\<%= addr.text\_field :zip, :class=\>‘quarter-size’ %\>  
\<%= addr.text\_field :state, :class=\>‘normal-size’ %\>  
  
  
\<%= addr.text\_field :county, :class=\>‘normal-size’ %\>  
\<%= addr.text\_field :country, :class=\>‘normal-size’ %\>  
\<% end %\>  
\<% end %\>

Here’s the error I get in my Customer.new method:

compile error  
script/…/config/…/app/views/customers/\_form.rhtml:12: parse error,  
unexpected kDO\_BLOCK  
\_erbout.concat “\t”; css\_fields\_for :address, do |addr| ;  
\_erbout.concat “\n”  
^  
script/…/config/…/app/views/customers/\_form.rhtml:25: parse error,  
unexpected kEND, expecting $

Extracted source (around line #12):

Thanks!

---

<div class="post-metadata">

**Author:** ![redbaritone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/779978/32.png) [@redbaritone](https://www.ruby-forum.com/u/redbaritone)\
**Post date:** [March 2, 2007, 3:56pm UTC](https://www.ruby-forum.com/t/css-fields-for-in-cssformbuilder/87427/2 "2007-03-02T15:56:33Z")

</div>

Hi Doug, (?)

redbaritone wrote:

> Trying to use CSSFormBuilder, but having a  
> problem with its css\_fields\_for wrapper.

I haven’t used this helper yet, but had a reader with a migrations  
problem  
recently and it sorta looks like the same thing. Same syntax in the  
line.  
Same error message. So here’s something to try.

> Here’s what I have:  
> \<% css\_fields\_for :address, do |addr| %\>
> 
> Here’s the error I get in my Customer.new method:  
> unexpected kDO\_BLOCK  
> \_erbout.concat “\t”; css\_fields\_for :address, do |addr| ;

Try removing the comma after :address. In a migration, it signals Rails  
(I  
think) to expect a directive (like :force =\> true) before the block.  
The  
reader got an ‘unexpected kDO\_BLOCK’ error when he had a comma but no  
directive, and the error went away when he removed the comma. Might be  
a  
similar situation here.

hth,  
Bill
