return NULL;
}
$fullDefn = FormDataModel::getField($apiEntity, $fieldName, 'create');
+
+ // we don't need to validate the file fields as it's handled separately
+ if ($fullDefn['input_type'] === 'File') {
+ return NULL;
+ }
+
$isRequired = $attributes['defn']['required'] ?? $fullDefn['required'] ?? FALSE;
if ($isRequired) {
$label = $attributes['defn']['label'] ?? $fullDefn['label'];
return str;
}
+ function validateFileFields() {
+ var valid = true;
+ $("af-form[ng-form=" + ctrl.getFormMeta().name +"] input[type='file']").each((index, fld) => {
+ if ($(fld).attr('required') && $(fld).get(0).files.length == 0) {
+ valid = false;
+ }
+ });
+ return valid;
+ }
+
this.submit = function() {
- if (!ctrl.ngForm.$valid) {
+ // validate required fields on the form
+ if (!ctrl.ngForm.$valid || !validateFileFields()) {
CRM.alert(ts('Please fill all required fields.'), ts('Form Error'));
return;
}