Skip to content
This repository

update field_error_proc leads conflict by change field_error_proc #985

Closed
halida opened this Issue February 16, 2012 · 4 comments

3 participants

Halida Benoit Bénézech Liel Dulev
Halida

in https://github.com/sferik/rails_admin/blob/master/app/helpers/rails_admin/form_builder.rb :

ActionView::Base.field_error_proc = Proc.new { |html_tag, instance| html_tag }

but in my application, I'm using client_side_validations, it use it to update form with error:

https://github.com/bcardarella/client_side_validations/blob/master/lib/generators/templates/client_side_validations/initializer.rb

 ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
   unless html_tag =~ /^<label/
     %{<div class="field_with_errors">#{html_tag}<label for="#{instance.send(:tag_id)}" class="message">#{instance.error_message.first}</label></div>}.html_safe
   else
     %{<div class="field_with_errors">#{html_tag}</div>}.html_safe
   end
 end

form_builder override my configuration, or my configuration override form_builder, any way to fix it?

Benoit Bénézech
Collaborator

Yeah, the only solution I can think is a wrapper like:

https://github.com/plataformatec/simple_form/blob/master/lib/simple_form/action_view_extensions/form_helper.rb#L48

field_error_proc is a total design failure (what was the guy thinking???)...

If you want to implement the aforementioned hack, RA form_builder is here:

https://github.com/sferik/rails_admin/blob/master/app/helpers/rails_admin/form_builder.rb

Have fun!

Halida

my solution, is to fork rails_admin, and delete field_error_proc:

https://github.com/halida/rails_admin

works for me.

Benoit Bénézech
Collaborator

This should be fixed. This can be an issue for other libraries/code.

Liel Dulev

+1

Benoit Bénézech bbenezech closed this issue from a commit September 11, 2012
Benoit Bénézech fix #985
shamelessly copied from simple_form
909e4a1
Benoit Bénézech bbenezech closed this in 909e4a1 September 11, 2012
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.