Skip to content

Conversation

@andrey-canon
Copy link
Collaborator

Description:

This PR implements the current capability of the Bragi theme to add fields that are conditionally displayed based on the values of other fields. The instructions include the necessary settings for the expected behavior in the specific example below:

  • If a user selects an occupation other than "employee," nothing will happen.
  • If the user selects "employee," a new field called sector will appear.
  • If the sector is different from "public," a text input will appear.

If the sector is "public," a field with limited options will appear, in this case using the value from the setting VALID_PUBLIC_SECTOR.

This example is specific to the current configuration. However, by modifying the settings, different conditional behaviors can be achieved.

How to test

  1. Add the following settings
VALID_PUBLIC_SECTORS = [
    "saudi_post",
    "communications_and_information_technology_commission",
    "ministry_of_communications_and_information_technology",
    "other"
]
CONDITIONAL_REGISTRATION_FIELDS = {
    "occupation": {
        "dependent_fields": {
            "employee": [
                "sector",
            ],
        },
        "key": "occupation",
        "options": [
            "employee",
            "student",
            "unemployed",
        ],
    },
    "public_sector": {
        "alias": "specific_sector",
        "options": VALID_PUBLIC_SECTORS,
    },
    "sector": {
        "dependent_fields": {
            "non_profit": [
                "specific_sector",
            ],
            "private": [
                "specific_sector",
            ],
            "public": [
                "public_sector",
            ]
        },
        "options": [
            "public",
            "private",
            "non_profit",
        ],
    },
}
REGISTRATION_EXTRA_FIELDS["sector"] = "optional"
REGISTRATION_EXTRA_FIELDS["specific_sector"] = "optional"
  1. Go to register page http://local.overhang.io:8000/register
  2. Check that the behavior is the expected, watch video for reference
2025-08-11.16-48-35.mp4

@OmarIthawi
Copy link
Collaborator

Thanks Andrey :)

@johanseto @shadinaif we need two reviewers for this PR.

cc: @andrey-canon

Copy link
Collaborator

@johanseto johanseto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  o            o__ __o    ____o__ __o____   o          o  
 <|>          /v     v\    /   \   /   \   <|\        /|> 
 / \         />       <\        \o/        / \\o    o// \ 
 \o/       o/                    |         \o/ v\  /v \o/ 
  |       <|       _\__o__      < >         |   <\/>   |  
 / \       \\          |         |         / \        / \ 
 \o/         \         /         o         \o/        \o/ 
  |           o       o         <|          |          |  
 / \ _\o__/_  <\__ __/>         / \        / \        / \ 
                                                          
                                                          
                                                          

Working in my local env

Screencast.from.08-09-25.17.47.35.webm
Screencast.from.08-09-25.17.48.43.webm
Screenshot from 2025-09-08 17-49-45

Copy link
Collaborator

@shadinaif shadinaif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, thank you!

@shadinaif shadinaif merged commit 2b6e96a into open-release/redwood.nelp Sep 17, 2025
@shadinaif shadinaif deleted the and/add_conditional_registration_fields branch September 17, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants