Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7041173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:00:25+00:00 2026-05-28T02:00:25+00:00

I would like to find a way to customize the default error html <div

  • 0

I would like to find a way to customize the default error html

<div class="field_with_errors"></div>

To take my own classes:

     <div class="clearfix error">
        <label for="errorInput">Input with error</label>
        <div class="input">
          <input class="xlarge error" id="errorInput" name="errorInput" size="30" type="text">
          <span class="help-inline">Small snippet of help text</span>
        </div>
      </div>

I have found this railscast from 2007 which uses Rails 2, I believe. http://railscasts.com/episodes/39-customize-field-error. It seems like Rails 3 might have a more friendly way to customize this html?

Also, it doesn’t show a way to just add an error class directly to the input like I want.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:00:26+00:00Added an answer on May 28, 2026 at 2:00 am

    The method explained in the link you posted is still used today with the vanilla form builders in Rails.

    So, if you wanted to wrap your input like you mention, create a method overriding the ActionView::Base.field_error_proc in your environment.rb file for example, like so:

    ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
      if instance.error_message.kind_of?(Array)
        %(<div class="form-field error">#{html_tag}<small class="error">&nbsp;
          #{instance.error_message.join(',')}</small></div).html_safe
      else
        %(<div class="form-field error">#{html_tag}<small class="error">&nbsp;
          #{instance.error_message}</small></div).html_safe
      end
    end
    

    In the above code, I’m wrapping my input (the #{html_tag}) in a <div class="form-field error>..</div> that’s the default used by ZURB Foundation. I’m also using a <small class="error">...</small tag (which is also the foundation default) to display the messages below the input.

    However, I recommend using a form builder gem like simple_form. It cleans up your view code quit a bit and allows for the level of customization you require.

    Check out the railscast on it here.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to find a way to take the object specific routine below
I would like to find some way of Viewing a Directory in the default
I would like to find a way to see what happens while my XAML
I would like to find a way to compile and package our iPhone application
I would like to find a way to use custom User provider within a
I would like to find a way to generate nice REST API documentation out
I would like to find a way (VB Script or PowerShell preferably) of generating
I would like to find a way to use the LaTeX \ref{} markup to
My boss would like to find a way for a running executable to ask
I am playing with JS.Class v.3.0 http://jsclass.jcoglan.com/ and I would like to find a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.