diff --git a/ext/afform/core/Civi/Afform/AfformMetadataInjector.php b/ext/afform/core/Civi/Afform/AfformMetadataInjector.php index ca20b3ac78f5..a26fc9ef338b 100644 --- a/ext/afform/core/Civi/Afform/AfformMetadataInjector.php +++ b/ext/afform/core/Civi/Afform/AfformMetadataInjector.php @@ -29,6 +29,11 @@ public static function preprocess($e) { try { $module = \Civi::service('angular')->getModule(basename($path, '.aff.html')); $meta = \Civi\Api4\Afform::get(FALSE)->addWhere('name', '=', $module['_afform'])->setSelect(['join_entity', 'entity_type'])->execute()->first(); + + // Add ngForm directive to afForm controllers + foreach (pq('af-form[ctrl]') as $afForm) { + pq($afForm)->attr('ng-form', $module['_afform']); + } } catch (\Exception $e) { } diff --git a/ext/afform/core/ang/af/afField.html b/ext/afform/core/ang/af/afField.html index 88e226c43b63..1965f74c7f62 100644 --- a/ext/afform/core/ang/af/afField.html +++ b/ext/afform/core/ang/af/afField.html @@ -1,5 +1,6 @@
{{:: $ctrl.defn.help_pre }}
diff --git a/ext/afform/core/ang/af/afForm.component.js b/ext/afform/core/ang/af/afForm.component.js index 888953f49988..c55dba4852cb 100644 --- a/ext/afform/core/ang/af/afForm.component.js +++ b/ext/afform/core/ang/af/afForm.component.js @@ -4,6 +4,9 @@ bindings: { ctrl: '@' }, + require: { + ngForm: 'form' + }, controller: function($scope, $element, $timeout, crmApi4, crmStatus, $window, $location, FileUploader) { var schema = {}, data = {}, @@ -83,6 +86,10 @@ } this.submit = function() { + if (!ctrl.ngForm.$valid) { + CRM.alert(ts('Please fill all required fields.'), ts('Form Error')); + return; + } status = CRM.status({}); $element.block(); @@ -92,7 +99,7 @@ values: data} ).then(function(response) { if (ctrl.fileUploader.getNotUploadedItems().length) { - _.each(ctrl.fileUploader.getNotUploadedItems(), function(file) { + _.each(ctrl.fileUploader.getNotUploadedItegitk&ms(), function(file) { file.formData.push({ params: JSON.stringify(_.extend({ token: response[0].token, diff --git a/ext/afform/core/ang/af/fields/ChainSelect.html b/ext/afform/core/ang/af/fields/ChainSelect.html index d1763602ff3f..ed756897ad8d 100644 --- a/ext/afform/core/ang/af/fields/ChainSelect.html +++ b/ext/afform/core/ang/af/fields/ChainSelect.html @@ -1 +1 @@ - + diff --git a/ext/afform/core/ang/af/fields/CheckBox.html b/ext/afform/core/ang/af/fields/CheckBox.html index f2edac2a4e5f..169baa2599b7 100644 --- a/ext/afform/core/ang/af/fields/CheckBox.html +++ b/ext/afform/core/ang/af/fields/CheckBox.html @@ -4,4 +4,4 @@ - + diff --git a/ext/afform/core/ang/af/fields/Date.html b/ext/afform/core/ang/af/fields/Date.html index 2707b64a4aa1..2722191d2881 100644 --- a/ext/afform/core/ang/af/fields/Date.html +++ b/ext/afform/core/ang/af/fields/Date.html @@ -1,6 +1,6 @@