Skip to content

Commit

Permalink
Merge pull request #21645 from colemanw/displayName
Browse files Browse the repository at this point in the history
Afform - Use search display name as field prefix for url-based field defaults
  • Loading branch information
eileenmcnaughton authored Oct 5, 2021
2 parents 19db696 + 0420c56 commit 3e2bee6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion ext/afform/core/ang/af/afField.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@
var index = ctrl.getEntityIndex();
uniquePrefix = entityName + (index ? index + 1 : '') + (joinEntity ? '.' + joinEntity : '') + '.';
}
// Set default value based on url
// Set default value from url with uniquePrefix + fieldName
if (urlArgs && urlArgs[uniquePrefix + ctrl.fieldName]) {
setValue(urlArgs[uniquePrefix + ctrl.fieldName]);
}
// Set default value from url with fieldName only
else if (urlArgs && urlArgs[ctrl.fieldName]) {
$scope.dataProvider.getFieldData()[ctrl.fieldName] = urlArgs[ctrl.fieldName];
}
// Set default value based on field defn
else if (ctrl.defn.afform_default) {
setValue(ctrl.defn.afform_default);
Expand Down
7 changes: 5 additions & 2 deletions ext/afform/core/ang/af/afFieldset.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
var self = ctrls[0];
self.afFormCtrl = ctrls[1];
},
controller: function($scope) {
controller: function($scope, $element) {
var ctrl = this,
localData = [];

this.getData = function() {
return ctrl.afFormCtrl ? ctrl.afFormCtrl.getData(ctrl.modelName) : localData;
};
// Get name of afform entity or search display
this.getName = function() {
return this.modelName;
return this.modelName ||
// If there is no Afform entity, get the name of embedded search display
$element.find('[search-name][display-name]').attr('display-name');
};
this.getEntityType = function() {
return this.afFormCtrl.getEntity(this.modelName).type;
Expand Down

0 comments on commit 3e2bee6

Please sign in to comment.