# Supressing output from FormBuilder helpers?

**URL:** <https://www.ruby-forum.com/t/supressing-output-from-formbuilder-helpers/110233>\
**Category:** Rails\
**Created:** [July 24, 2007, 3:05pm UTC](https://www.ruby-forum.com/t/supressing-output-from-formbuilder-helpers/110233 "2007-07-24T15:05:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndyV](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9fc29f/32.png) [@AndyV](https://www.ruby-forum.com/u/AndyV)\
**Post date:** [July 24, 2007, 3:05pm UTC](https://www.ruby-forum.com/t/supressing-output-from-formbuilder-helpers/110233/1 "2007-07-24T15:05:36Z")

</div>

The FormBuilder helper is called like this:  
\<% field\_validator :object, :name, {options} %\>

The options hash is used to specify the different types of validation  
for the field (required, numeric, regex, etc). This is where the  
problem comes in as well. The helper eventually defers to the  
following:

```
  def field_validator_tag(field_id, options={})
    # Raise an error if a requested validation type is not

```

recognized  
raise(ArgumentError, “Missing validator options”) if  
options.empty?  
raise(ArgumentError, “Unrecognized validation options.  
field\_validator recognizes: #{FIELD\_VALIDATIONS.join(’, ')}”) unless  
(options.keys-FIELD\_VALIDATIONS).empty?

```
    # Build up a string of the requested validations
    options.each do |validation_name, validation_options|

```

@field\_validations.push( _validation\_constructor\_string\_omitted_ );  
end  
end

The problem is that a side effect of iterating over the options hash  
is that the hash elements are emitted and end up on the page in the  
place where the field\_validator is called. That is, if I have  
something like this:

\<% validated\_form\_for :widget, :url=\>widgets\_path, :method=\>:post %\>

Age \<%= f.text\_field :age %\> \<%= field\_validator :widget, :name, :required=\>true, :numeric=\>true %\>

... \<% end %\>

I end up with rendered markup like this:

Age requiredtruenumerictrue

 ...

Any ideas how I can supress the output from the iteration?  
(Incidentally, I know that it’s the iteration itself because I’ve  
commented out the single line in the block and still get the keys  
rendered in the page).
