No commit activity in last 3 years
No release in over 3 years
Extend ActionView::Helepr::FormHelper for rendering error message with using rails form_for.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

FormHelper::ErrorMessages

Extend ActionView::Helepr::FormHelper for rendering error message on any position.

Installation

Add this line to your application's Gemfile:

gem 'form_helper-error_messages'

And then execute:

$ bundle

Or install it yourself as:

$ gem install form_helper-error_messages

Usage

# You can put error message any position.
<%= from_for(@user) do |f| %>
  <%= f.text_field :name %>
  <%= f.error_messages :name %>
<% end %>

# <form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div>
# <div class="invalid">Name can&#x27;t be blank</div>
# </form>

You can choose any tags or any class name like this.

<%= from_for(@user) do |f| %>
  <%= f.text_field :name %>
  <%= f.error_messages :name, tag: 'span', class: 'error' %>
<% end %>

# <form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
# <div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div><span class="error">Name can&#x27;t be blank</span></form>

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request