# Need help with @template.content\_tag

**URL:** <https://www.ruby-forum.com/t/need-help-with-template-content-tag/132878>\
**Category:** Rails\
**Created:** [March 25, 2008, 2:49pm UTC](https://www.ruby-forum.com/t/need-help-with-template-content-tag/132878 "2008-03-25T14:49:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [March 25, 2008, 2:49pm UTC](https://www.ruby-forum.com/t/need-help-with-template-content-tag/132878/1 "2008-03-25T14:49:18Z")

</div>

Hi all

I have my own FormBuilder. One of its functionalities is to group fields  
using the following method:

def group\_fields(legend, options = {}, &block)  
concat(@template.content\_tag(‘fieldset’,  
@template.content\_tag(‘legend’,  
legend  
) + capture(&block), options),  
block.binding)  
end

This just creates a fieldset tag and puts the fields into it:

form.group\_fields(‘Caption…’) do |group|  
group.text\_area(:asdf)  
end

Now I need to modify it a little bit for design purposes: I need another  
div around the fields! But I just seem to be unable to modify it the way  
it should be modified! I always get compile errors and stuff. 😉

Maybe a more experienced coder can help me?

Thanks a lot  
Josh

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [March 25, 2008, 5:49pm UTC](https://www.ruby-forum.com/t/need-help-with-template-content-tag/132878/2 "2008-03-25T17:49:30Z")

</div>

On Mar 25, 2008, at 9:49 AM, Joshua M. wrote:

> Hi all
> 
> I have my own FormBuilder. One of its functionalities is to group  
> fields  
> using the following method:
> 
> def group\_fields(legend, options = {}, &block)  
> concat(  
> @template.content\_tag(‘div’,  
> @template.content\_tag(‘fieldset’,  
> @template.content\_tag(‘legend’,  
> legend  
> ) + capture(&block)  
> , :any =\> ‘stuff’, :for =\> ‘the div’)  
> , options),  
> block.binding)  
> end

Does that do what you want? (after you put the lines that start with  
commas back together with the previous line, of course)

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [March 26, 2008, 1:29pm UTC](https://www.ruby-forum.com/t/need-help-with-template-content-tag/132878/3 "2008-03-26T13:29:44Z")

</div>

> Does that do what you want? (after you put the lines that start with  
> commas back together with the previous line, of course)
> 
> -Rob
> 
> Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
> removed\_email\_address@domain.invalid

Oh, everything was perfectly correct, I just had an invalid XHTML  
structure and I was too lazy to check the output source code… 😉 So  
the problem was not this method.

Thanks anyway.
