I was recently playing around with rendering inline errors using the normal Ruby on Rails view stack, when I came across this blog post. There’s certainly some interesting stuff in there, but one of the things that stuck out to me particularly is how the field_error_proc attached to the base ActionView class can be modified to render inline errors by default.
I did some looking around to try and learn more about how this proc is inserted into forms built with the Rails form helpers, and I struggled to find information on the topic. I couldn’t find anything exposed on the API docs, and the only thing that I found in Rails Guides is this section on changing the proc using the Rails’ configuration features. A particularly frustrating part of this is not knowing how the Rails form builder processes this proc, and what methods the default arguments for this proc respond to.
I was wondering if anyone could provide some historical context as to why this feature exists as part of the form builder, and if there’s a prescribed way to interact with it. Given current trends in web design, it seems like this could be a really useful feature, but it seems to be something that’s difficult to find information on, and that many people don’t take advantage of.
I hope that this topic can spark some conversation around the feature. I’d love to hear all of your experiences or insights into this topic.
Hey! Thanks for taking the time to share your thoughts on the subject.
I think rolling something like this into the form builder API could work really well! I think this could also help cover the gap in documentation for the feature.
I’d love to offer some commentary or assistance with the PR, but unfortunately I’m a pretty amateur developer. If you have some kind of direction or architecture suggestions, I think I could be able to help from there. I just don’t want to offer uneducated advice.
html_tag is just the string representing the inner tag, but instance isn’t very clear. I logged what it is, and think they are all subclasses of ActionView::Helpers::Tags::Base representing the one kind of tag. This isn’t very well documented either, but the object being the activemodel itself means we can access errors information.