}
$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';
// 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;
};
(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}
});
});