Search code examples
stormpath

Can't add custom field from registration form in AngularJS + Stormpath


I want to add a custom field during new user registration but it shows an error message:

is not a configured registration field.

But documentation on page https://docs.stormpath.com/angularjs/sdk/#/api/stormpath.spRegistrationForm:spRegistrationForm states:

Any form fields you supply that are not one of the default fields (first name, last name) will be automatically placed into the new account's customa data object.

The code I use:

<form ng-submit="submit()">
	<div class="form-group">
		<input type="text" class="form-control" placeholder="First Name" ng-model="formModel.givenName" required="" ng-disabled="creating">
	</div>
	<div class="form-group">
		<input type="text" class="form-control" placeholder="Last Name" ng-model="formModel.surname" required="" ng-disabled="creating">
	</div>
	<div class="form-group">
		<input type="email" class="form-control" placeholder="Email" ng-model="formModel.email" required="" ng-disabled="creating">
	</div>
	<div class="form-group">
		<input type="password" class="form-control" placeholder="Password" ng-model="formModel.password" required="" ng-disabled="creating">
	</div>
	<div class="form-group">
		<input type="text" class="form-control" placeholder="Custom field" ng-model="formModel.customfield" required="" ng-disabled="creating">
	</div>
  
	<p class="alert alert-danger" ng-show="error>
	<button type="submit" class="btn btn-primary" ng-disabled="creating">Register</button>
</form>

How can I add custom field on registration form?


Solution

  • From the error message it sounds like you are using our Express-Stormpath library on your backend (please let me know if this is not correct).

    You will need to configure your fields in the Express server as well. We require sever-side form configuration as well, to prevent arbitrary requests to the user's custom data object.

    Documentation on the form configuration can be found here:

    http://docs.stormpath.com/nodejs/express/latest/registration.html#creating-custom-fields

    Hope this helps! P.S. I work at Stormpath :)