-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add how-to for extending registration form with dynamic fields #1238
base: master
Are you sure you want to change the base?
docs: add how-to for extending registration form with dynamic fields #1238
Conversation
Thanks for the pull request, @GlugovGrGlib! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Hi @openedx/2u-vanguards! Just following up on this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are the exact steps I had to go through in order to enable an extra field(s).
Note: This below example and cause, is for when the field that is required to be activated is already is this list EXTRA_FIELDS.
The fields that are in EXTRA_FIELDS are already exists as column in userprofile model, but are disbaled, so when adding other field that don't exits, a step to do data migration is required.
Tutor file plugin to set ENABLE_DYNAMIC_REGISTRATION_FIELDS
it at LMS/backend:
from tutor import hooks
hooks.Filters.ENV_PATCHES.add_item(
("openedx-lms-common-settings",
"""
ENABLE_DYNAMIC_REGISTRATION_FIELDS = True
"""
)
)
Then change site_configuration in django admin for:
1- ENABLE_DYNAMIC_REGISTRATION_FIELDS
at MFE_CONFIG level
2- Set REGISTRATION_EXTRA_FIELDS
(as example in sippest below we flag country
and gender
as required
which are by default hidden
, it could also be as optional
)
{
"REGISTRATION_EXTRA_FIELDS": {
"country": "required",
"gender": "required"
},
"MFE_CONFIG": {
"ENABLE_DYNAMIC_REGISTRATION_FIELDS": "true"
}
}
I think this PR as it's handles the case when a new field is to add/enable that doesn't exists in EXTRA_FIELDS.
Hi @openedx/vanguards @openedx/vanguards - Friendly ping on this. We'll rerun tests when we confirm if someone can review from your team. Thanks! |
{ | ||
"ENABLE_DYNAMIC_REGISTRATION_FIELDS": "true", | ||
"MFE_CONFIG": { | ||
"ENABLE_DYNAMIC_REGISTRATION_FIELDS": "true" | ||
}, | ||
"REGISTRATION_EXTRA_FIELDS": { | ||
"country": "required", | ||
"gender": "required" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't so much readable in the preview. Could you please fix it?
- All possible fields can be find in `EXTRA_FIELDS <https://github.com/openedx/edx-platform/blob/a9355852edede9662762847e0d168663083fc816/openedx/core/djangoapps/user_authn/api/helper.py#L20-L39>`_. | ||
- REST API gets cached, if you are in hurry though you can do this command: `tutor local exec redis redis-cli flushall`. | ||
- Or you can wait a few minutes until the cache is invalidated. | ||
- After this, the new fields should appear on the Auth page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT:
Can we also mention that the required fields will appear on the registration form and optional fields will appear on progressive profiling form?
.. code-block:: python | ||
ENABLE_DYNAMIC_REGISTRATION_FIELDS = "true" | ||
|
||
MFE_CONFIG["ENABLE_DYNAMIC_REGISTRATION_FIELDS"] = "true" | ||
|
||
REGISTRATION_EXTRA_FIELDS["country"] = "required" | ||
|
||
REGISTRATION_EXTRA_FIELDS["gender"] = "required" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please fix its preview?
`In total, you must redefine 3 constants using the method that is most preferable for you:` **ENABLE_DYNAMIC_REGISTRATION_FIELD = True, MFE_CONFIG["ENABLE_DYNAMIC_REGISTRATION_FIELDS"] = True, REGISTRATION_EXTRA_FIELDS["field_name"] = "required/optionl/hidden"**. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please write these CONSTS in a code block for better preview.
Hi @GlugovGrGlib, Thanks for the contribution. This looks good—just some small thoughts. |
Co-authored-by: Syed Sajjad Hussain Shah <52817156+syedsajjadkazmii@users.noreply.github.com>
Co-authored-by: Syed Sajjad Hussain Shah <52817156+syedsajjadkazmii@users.noreply.github.com>
39bd8d3
to
cf2877b
Compare
Hi @syedsajjadkazmii! |
REGISTRATION_EXTRA_FIELDS["field_name"] = "required/optionl/hidden" | ||
|
||
|
||
**B. Add fields that do not exist in the user profile model** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @GlugovGrGlib
I was working on an extended registration form for an openedx instance and face some issues to make it work along with the authn MFE. While doing some research on the possible workarounds I came across with this PR.
Just want to know if you have had the opportunity to test the implementation of an extended registration form along with this MFE? Because I found a conflict between the django model/form definitions and the MFE structure and the way the MFE handles the fields definition.
The purpose of this whole comment is to double check if the steps documented in this B section were already proven since I've follow the exact same steps and haven't make it work, so it would be cool if we confirm that the Authn MFE supports the extended forms or if it's a future work needed to be doing in another PR.
Description
This PR is adding how-to guide for extending registration form with custom filed in Authn MFE.
Additional details
Closing issue #923.