Skip to content

Instantly share code, notes, and snippets.

@travist
Last active July 12, 2018 02:34
Show Gist options
  • Save travist/293063135cf0c58eb78354c95f7a8378 to your computer and use it in GitHub Desktop.
Save travist/293063135cf0c58eb78354c95f7a8378 to your computer and use it in GitHub Desktop.
Auto-populate a field with data
FormioResourceProvider.register('todo', AppConfig.forms.todoForm, {
defaultValue: {data: {status: 'notstarted'}},
templates: {
view: 'views/todo/view.html'
},
controllers: {
create: ['$scope', '$rootScope', function($scope, $rootScope) {
$rootScope.whenReady.then(function() {
$scope.submission = {data: {
email: $rootScope.user.data.email
}};
});
}],
view: ['$scope', function($scope) {
$scope.position = {lat: '40.74', lng: '-74.18'};
$scope.currentResource.loadSubmissionPromise.then(function() {
if (!$scope.currentResource.resource) { return; }
if ($scope.currentResource.resource.data.address) {
$scope.position.lat = $scope.currentResource.resource.data.address.geometry.location.lat;
$scope.position.lng = $scope.currentResource.resource.data.address.geometry.location.lng;
}
});
}]
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment