-
Notifications
You must be signed in to change notification settings - Fork 533
Validator: Field validated class #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Good idea. What is your suggestion? |
@lionel-bijaoui Totally agree that there should be a another state which is the "initial" state before validating a field. |
I was thinking of using // formGenerator.vue
methods: {
// Get style classes of field
getFieldRowClasses(field) {
const hasErrors = this.fieldErrors(field).length > 0;
let baseClasses = {
error: hasErrors,
disabled: this.fieldDisabled(field),
readonly: this.fieldReadonly(field),
featured: this.fieldFeatured(field),
required: this.fieldRequired(field)
};
let { validationErrorClass, validationSuccessClass } = this.options;
if (validationErrorClass && validationSuccessClass) {
if (fieldInitial) {
baseClasses[validationErrorClass] = false;
baseClasses[validationSuccessClass] = false;
} else {
if (hasErrors) {
baseClasses[validationErrorClass] = true;
baseClasses.error = false;
} else {
baseClasses[validationSuccessClass] = true;
}
}
}
if (isArray(field.styleClasses)) {
each(field.styleClasses, (c) => baseClasses[c] = true);
} else if (isString(field.styleClasses)) {
baseClasses[field.styleClasses] = true;
}
baseClasses["field-" + field.type] = true;
return baseClasses;
},
/* ... */
fieldInitial(field) {
return field.vfg_ValidationState;
},
/* ... */
} |
Seems ok. I would probably give it a different naming
|
Since this is used by all fields, I think we should at least namespace the internal properties with |
That's fine I guess |
@icebob I have a hard time making this work. |
What is the status of this? Still |
Hello @icebob , I've been extremely busy at work. |
Hi @icebob @dflock @cristijora,
I need a validated state (class) for my fields.
I noticed in the source that there is a
validationSuccessClass
and by setting it withvalidationErrorClass
, I can get a class that currently correspond to "no error".But "no error" and "validated" don't have the same meaning.
A field should have 3 states : "normal", "error" and "validated".
With
validateAfterLoad: false, validateAfterChanged: false
, I want my field to be "normal" until I trigger a validation. Then all fields are either "error" or "validated".With
validateAfterLoad: false, validateAfterChanged: true
, I want my field to be "normal" until I edit the field. Then this field is either "error" or "validated".With
validateAfterLoad: true, validateAfterChanged: false
, I want all my fields to be either "error" or "validated" after initial load. They keep their state until I trigger a validation.With
validateAfterLoad: true, validateAfterChanged: true
, I want all my fields to be either "error" or "validated" after initial load. They keep their state until I edit the field.With this behavior, it will be possible to add a checkmark or anything I want next to each "validated" field. It will allow my users to see their progress on the from.
TL:DR The goal is to have a class that mean "I have been through the validation process at least once and I have no error"
How can we achieve that ?
I can do a PR if necessary but I wanted your opinion on the issue first.
Thank you !
The text was updated successfully, but these errors were encountered: