update field_error_proc leads conflict by change field_error_proc #985

Closed
halida opened this Issue Feb 17, 2012 · 4 comments

Projects

None yet

3 participants

@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?

@bbenezech
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.

@bbenezech
Collaborator

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

@bbenezech bbenezech was assigned Apr 7, 2012
@bbenezech bbenezech added a commit that closed this issue Sep 11, 2012
@bbenezech bbenezech fix #985
shamelessly copied from simple_form
909e4a1
@bbenezech bbenezech closed this in 909e4a1 Sep 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment