From 0853eb5fb8ad0b7f29c06c6e4e86f8f27f96699e Mon Sep 17 00:00:00 2001 From: Dennis Chan Date: Mon, 3 Jun 2024 16:34:28 -0400 Subject: [PATCH] Add documentation to main js file --- addon/components/form-field.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addon/components/form-field.js b/addon/components/form-field.js index a7c3533..cf5e1ac 100644 --- a/addon/components/form-field.js +++ b/addon/components/form-field.js @@ -3,6 +3,17 @@ import { isPresent } from '@ember/utils'; import { computed } from '@ember/object'; import Component from '@ember/component'; +// +// A generic wrapper around a form element (input, select, radios) +// +// By providing this component with an attribute name on a model, this component will auto-detect any validation errors (from DS.Errors) +// on the specified attribute, and apply appropriate error classes and error messages to the field. +// +// This component also support custom errors that is not part of the model (client-side validations, for example). +// Although comprehensive client-side validation libraries are available, we do not currently need the full capability of those libraries and a simple custom error string will do. +// +// This component is a modified and simplified version of https://alexspeller.com/server-side-validations-with-ember-data-and-ds-errors/ +// export default Component.extend({ classNameBindings: [':form-group', 'hasError:has-error'],