Forum: Ruby on Rails Supressing output from FormBuilder helpers?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
9a71df6388c8d37bfdf0e18742ea944a?d=identicon&s=25 AndyV (Guest)
on 2007-07-24 15:05
(Received via mailing list)
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

      def field_validator_tag(field_id, options={})
        # Raise an error if a requested validation type is not
        raise(ArgumentError, "Missing validator options") if
        raise(ArgumentError, "Unrecognized validation options.
field_validator recognizes: #{FIELD_VALIDATIONS.join(', ')}") unless

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

@field_validations.push( _validation_constructor_string_omitted_ );

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 %>
<label for="widget_age">Age</label>
<%= f.text_field :age %>
<%= field_validator :widget, :name, :required=>true, :numeric=>true %>
<% end %>

I end up with rendered markup like this:

<form action="/widgets" id="widget_form" method="post"
    <label for="widget_age">Age</label>
    <input id="widget_age" name="widget[age]" size="30" type="text" />

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).
This topic is locked and can not be replied to.