Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Helper pour modifier un field de form quand il y a un erreur

View form.html.erb
1 2 3 4 5 6 7 8
<% field_with_errors @zonage, :name do %>
<div class="control-group">
<%= f.label 'Nom du zonage', :class => 'control-label' %>
<div class="controls">
<%= f.text_field :name %>
</div>
</div>
<% end %>
View form.html.erb
1 2 3 4 5 6 7 8 9 10 11 12
# http://lukecarrier.me/2011/08/rails-3-0-select-tags-and-field_with_errors/
# modified for replacer a class
def field_with_errors(object, method, &block)
if block_given?
if object.errors[method].empty?
concat capture(&block)
else
add_error = capture(&block).gsub("control-group", "control-group error")
concat raw(add_error)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.