How to modify RegisterForm in flask security to add the values from a field to different table

43 Views Asked by At

I have added a field to the RegisterForm of flask security and the field is being rendered on the register page. The modified form is as follows-

class Registerform_roles(RegisterForm):
    role = SelectField(label="Role", \
                    validators=[
                        validators.data_required(),
                        unique_identity_attribute
                    ],\
                    choices=['a','b','c']
                )

I want the values from this field to be saved to a different table in the datastore instead of the User table whenever the form is submitted. I wasn't able to find the part of the code that handles the post request from the register page. Any ideas on how to do this?

1

There are 1 best solutions below

2
jwag On

One thing to try is to set up a signal handler for 'user_registered' - that will receive the entire form as well as the User that was just registered.