From: Tim Otten Date: Wed, 13 Jun 2018 06:40:26 +0000 (-0700) Subject: Expose the `meta` field in the form scope X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f4017340788eeec281739a34f5dd53868764b080;p=civicrm-core.git Expose the `meta` field in the form scope --- diff --git a/ext/afform/afform.php b/ext/afform/afform.php index 2ec594afa9..a0566f066d 100644 --- a/ext/afform/afform.php +++ b/ext/afform/afform.php @@ -186,13 +186,15 @@ function afform_civicrm_buildAsset($asset, $params, &$mimeType, &$content) { } $name = $params['name']; - $meta = civicrm_api3('Afform', 'getsingle', ['name' => $name]); + $scanner = new CRM_Afform_AfformScanner(); + $meta = $scanner->getMeta($name); $scanner = new CRM_Afform_AfformScanner(); $smarty = CRM_Core_Smarty::singleton(); $smarty->assign('afform', [ 'camel' => _afform_angular_module_name($name), 'meta' => $meta, + 'metaJson' => json_encode($meta), 'layout' => file_get_contents($scanner->findFilePath($name, 'layout.html')) ]); $mimeType = 'text/javascript'; diff --git a/ext/afform/ang/afformCore.js b/ext/afform/ang/afformCore.js index 2488968454..7548db1f5c 100644 --- a/ext/afform/ang/afformCore.js +++ b/ext/afform/ang/afformCore.js @@ -6,13 +6,14 @@ // Use `afformCoreDirective(string name)` to generate an AngularJS directive. angular.module('afformCore').service('afformCoreDirective', function($routeParams){ - return function(camelName, d){ + return function(camelName, meta, d){ d.restrict = 'AE'; d.scope = {}; d.scope.options = '=' + camelName; d.link = function($scope, $el, $attr) { $scope.ts = CRM.ts(camelName); $scope.routeParams = $routeParams; + $scope.meta = meta; }; return d; }; diff --git a/ext/afform/templates/afform/FormAsDirective.tpl b/ext/afform/templates/afform/FormAsDirective.tpl index f448ad4406..ec8511c82a 100644 --- a/ext/afform/templates/afform/FormAsDirective.tpl +++ b/ext/afform/templates/afform/FormAsDirective.tpl @@ -8,7 +8,7 @@ (function(angular, $, _) { angular.module('{/literal}{$afform.camel}{literal}', CRM.angRequires('{/literal}{$afform.camel}{literal}')); angular.module('{/literal}{$afform.camel}{literal}').directive('{/literal}{$afform.camel}{literal}', function(afformCoreDirective) { - return afformCoreDirective({/literal}{$afform.camel|json}{literal}, { + return afformCoreDirective({/literal}{$afform.camel|json},{$afform.metaJson}{literal}, { template: {/literal}{$afform.layout|json}{literal} }); });