reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

validation states error message #80

Closed teaforthecat closed 8 years ago

teaforthecat commented 8 years ago

Any thoughts on how we could add an error message or change the label of a field depending on the validation state? I'm thinking it would be another field type like this [:div {:field :error}], adding to the bind and init-field multi-methods. Does that sound right? This idea would be in correlation with #62

yogthos commented 8 years ago

yeah that should work, sounds similar to the alert element

teaforthecat commented 8 years ago

In taking a second look, it looks like the :label field would work. Here's what I came up with:

[:label.control-label {:for id :placeholder label :id [:errors id :label] :field :label}]

Also when the label shouldn't change, and you just want an inline error message:

[:div.error_message {:field :label :id [:errors id :message] }]

Pretty simple, no change needed. Thanks!

yogthos commented 8 years ago

excellent :)