meteor-cfs-autoform
meteor-cfs-autoform copied to clipboard
No way to make a file field mandatory
Currently it is not possible to make a file field mandatory because it has "dummyId" value and passes the form validation.
Handling formToDoc, docToForm, formToModifier hooks of AutoForm could help invalidating the form if the field is not optional.
@romaroma any workaround found??
@dmeneses no unfortunately, we currently use extra validation on the client side:
if (insertDoc[key] === 'dummyId') {
insertDoc[key] = $('input[name=' + key + ']').attr('data-id');
if (!insertDoc[key]) {
isValid = false;
// raise an autoform error
context.addInvalidKeys([{name: key, type: 'required'}]);
}
}
Actual value of the field is stored in data-id
attribute of an extra hidden field, so we just copy it and compare with false
.