RRUI-001 · Form fields · Validation
After a failed save, f.rui_input / f.rui_textarea used to re-render with no field error text and no invalid styling — even though the model had errors. Select already did this correctly.
| Components |
RapidRailsUI::Input::Component, RapidRailsUI::Textarea::Component
|
|---|---|
| Status | Fixed in 0.51.2
|
| Cause | Pre-standard components never retrofitted to the shared server-error path |
| Now | Field error message + invalid border + aria, matching Select |
f.rui_input(:email, type: :email, required: true) to an ActiveRecord model.status: :unprocessable_entity.required if needed so the request reaches the server).aria-invalid.f.rui_select — first model error under the field, invalid border, aria-invalid="true".input_validation_controller / textarea_validation_controller skipped validation on connect. After a 422 replace, nothing painted the server error until SSR used field_has_error? / error_message.
def field_has_error?
@form && @method && @form.object.errors[@method].present?
end
def error_message
return nil unless field_has_error?
@form.object.errors[@method].first
end
<% if validation %>
<p id="<%= validation_message_id %>"
class="<%= VALIDATION_MESSAGE_CLASSES %>"
role="alert"
data-…-target="message"></p>
<% end %>
Always empty. Select already did:
<% if render_error_message? %>
<p class="<%= ERROR_CLASSES %>" role="alert">
<%= error_message %>
</p>
<% end %>
connect() {
// Don't validate on connect - wait for user interaction.
}
field_has_error?, render error_message into the validation message element (SSR).aria-invalid="true" on the control.0.53.0 audit tightened error a11y across every field.