update field_error_proc leads conflict by change field_error_proc #985

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

Comments

Projects
None yet
3 participants
@halida

halida commented Feb 17, 2012

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

This comment has been minimized.

Show comment
Hide comment
@bbenezech

bbenezech Feb 17, 2012

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!

Collaborator

bbenezech commented Feb 17, 2012

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

This comment has been minimized.

Show comment
Hide comment
@halida

halida Feb 17, 2012

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

https://github.com/halida/rails_admin

works for me.

halida commented Feb 17, 2012

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

https://github.com/halida/rails_admin

works for me.

@bbenezech

This comment has been minimized.

Show comment
Hide comment
@bbenezech

bbenezech Apr 7, 2012

Collaborator

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

Collaborator

bbenezech commented Apr 7, 2012

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

@ghost ghost assigned bbenezech Apr 7, 2012

@lieldulev

This comment has been minimized.

Show comment
Hide comment
@lieldulev

lieldulev Jul 13, 2012

+1

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment