diff --git a/guacamole/src/main/webapp/app/form/controllers/textFieldController.js b/guacamole/src/main/webapp/app/form/controllers/textFieldController.js index b5bc7538f..8dd134ab5 100644 --- a/guacamole/src/main/webapp/app/form/controllers/textFieldController.js +++ b/guacamole/src/main/webapp/app/form/controllers/textFieldController.js @@ -35,6 +35,6 @@ angular.module('form').controller('textFieldController', ['$scope', '$injector', // Generate unique ID for datalist, if applicable if ($scope.field.options && $scope.field.options.length) - $scope.dataListId = $scope.field.name + '-datalist'; + $scope.dataListId = $scope.fieldId + '-datalist'; }]); diff --git a/guacamole/src/main/webapp/app/form/directives/formField.js b/guacamole/src/main/webapp/app/form/directives/formField.js index c2479fa65..81dacdf2a 100644 --- a/guacamole/src/main/webapp/app/form/directives/formField.js +++ b/guacamole/src/main/webapp/app/form/directives/formField.js @@ -72,6 +72,18 @@ angular.module('form').directive('guacFormField', [function formField() { */ var fieldContent = $element.find('.form-field'); + /** + * An ID value which is reasonably likely to be unique relative to + * other elements on the page. This ID should be used to associate + * the relevant input element with the label provided by the + * guacFormField directive, if there is such an input element. + * + * @type String + */ + $scope.fieldId = 'guac-field-XXXXXXXXXXXXXXXX'.replace(/X/g, function getRandomCharacter() { + return Math.floor(Math.random() * 36).toString(36); + }) + '-' + new Date().getTime().toString(36); + /** * Produces the translation string for the header of the field with * the given name. If no name is supplied, then the name of the diff --git a/guacamole/src/main/webapp/app/form/services/formService.js b/guacamole/src/main/webapp/app/form/services/formService.js index 92be21d01..cc0a24043 100644 --- a/guacamole/src/main/webapp/app/form/services/formService.js +++ b/guacamole/src/main/webapp/app/form/services/formService.js @@ -234,6 +234,11 @@ angular.module('form').provider('formService', function formServiceProvider() { * A String which defines the unique namespace associated the * translation strings used by the form using a field of this type. * + * fieldId: + * A String value which is reasonably likely to be unique and may + * be used to associate the main element of the field with its + * label. + * * field: * The Field object that is being rendered, representing a field of * this type. diff --git a/guacamole/src/main/webapp/app/form/templates/checkboxField.html b/guacamole/src/main/webapp/app/form/templates/checkboxField.html index ad9d8e006..110ab14a6 100644 --- a/guacamole/src/main/webapp/app/form/templates/checkboxField.html +++ b/guacamole/src/main/webapp/app/form/templates/checkboxField.html @@ -1 +1,5 @@ - \ No newline at end of file + diff --git a/guacamole/src/main/webapp/app/form/templates/dateField.html b/guacamole/src/main/webapp/app/form/templates/dateField.html index a186e19a5..2da96a12b 100644 --- a/guacamole/src/main/webapp/app/form/templates/dateField.html +++ b/guacamole/src/main/webapp/app/form/templates/dateField.html @@ -1,5 +1,6 @@
{{model}} -
\ No newline at end of file + diff --git a/guacamole/src/main/webapp/app/form/templates/formField.html b/guacamole/src/main/webapp/app/form/templates/formField.html index 45cf6b912..3e45d4cb6 100644 --- a/guacamole/src/main/webapp/app/form/templates/formField.html +++ b/guacamole/src/main/webapp/app/form/templates/formField.html @@ -1,9 +1,11 @@ -