Open alphamarket opened 7 years ago
To my knowledge there is no way to explicitly pass in errors. The form simply delegates to the errors
attribute of your model, as you can see here:
I see.... although I come up with a workaround for this, but how about we add a new option named error
for the tags which the user can pass the custom error(like the example above), IF no error
passed, then the BS_form consider the object
's error?
how about we add a new option named
error
for the tags which the user can pass the custom error
To be honest, this is not a pattern that I wantbootstrap_form
to encourage right now. I think using ActiveRecord's errors
attribute is the best solution for most people.
That said, I see how it could come in handy for some edge cases such as yours. If you (or another interested contributor) would like to put together a PR, I'll consider merging it if the implementation is clean and well-tested.
I think this could be a thing. Bootstrap 4 allows setting predefined invalid-feedback
on form elements for JS validation. See: https://getbootstrap.com/docs/4.0/components/forms/#validation
I makes sense to allow setting it to whatever you want. Errors that come from Rails during form render will replace default messages.
I have a huge complicated form which contains with multiple subforms(in some loops) with custom namings and etc... I process data and validate each model and extract the following error structure:
I can say which elements are belong to which
[:spec]/[:section]
but there is no documentation on how can I pass the:errors
to the tag? i.e Is there anything like the following in the api?Thanks in advance.