Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Commit 971cd61

Browse files
author
Kent C. Dodds
committed
Improved README and $scope.id setting to be more explicit.
1 parent 6ff682d commit 971cd61

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ Forms can be customized with the options below.
9292
>`submitCopy` customizes the submit button copy. Defaults to 'Submit'.
9393
9494
### Creating Form Fields
95-
When constructing fields use the options below to customize each field object. You must set at least a `type` or `templateUrl`.
95+
When constructing fields use the options below to customize each field object. You must set at least a `type`, `template`, or `templateUrl`.
9696

9797
##### type (string)
98-
>`type` is the type of field to be rendered. Either type or templateUrl must be set.
98+
>`type` is the type of field to be rendered. Either type, template, or templateUrl must be set.
9999
100100
###### Default
101101
>`null`
@@ -113,14 +113,14 @@ When constructing fields use the options below to customize each field object. Y
113113
114114
---
115115
##### template (string)
116-
>`template` can be set instead of `type` to use a custom html template form field. Should be used with one-liners mostly (like a directive). Useful for adding functionality to fields.
116+
>`template` can be set instead of `type` or `templateUrl` to use a custom html template form field. Should be used with one-liners mostly (like a directive). Useful for adding functionality to fields.
117117
118118
###### Default
119119
>`undefined`
120120
121121
---
122122
##### templateUrl (string)
123-
>`templateUrl` can be set instead of `type` to use a custom html template form field. Set a path relative to the root of the application. ie `directives/custom-field.html`
123+
>`templateUrl` can be set instead of `type` or `template` to use a custom html template form field. Set a path relative to the root of the application. ie `directives/custom-field.html`
124124
125125
###### Default
126126
>`undefined`

src/directives/formly-field.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,15 @@ angular.module('formly.render')
7878
if (typeof $scope.options.default !== 'undefined') {
7979
$scope.value = $scope.options.default;
8080
}
81+
var type = $scope.options.type;
82+
if (!type && $scope.options.template) {
83+
type = 'template';
84+
} else if (!type && $scope.options.templateUrl) {
85+
type = 'templateUrl';
86+
}
8187

8288
// set field id to link labels and fields
83-
$scope.id = $scope.formId + ($scope.options.type || 'Custom') + $scope.index;
89+
$scope.id = $scope.formId + type + $scope.index;
8490
}
8591
};
8692
});

0 commit comments

Comments
 (0)