You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generates suitable field prompts for a name based on the type of entity (person or business)
@@ -1133,6 +1134,7 @@ def name_fields(
1133
1134
maxlengths (Dict[str, int], optional): A dictionary of field names and their maximum lengths. Default is None.
1134
1135
suffix_choices (Union[List[str], Callable], optional): A list of suffix options or a callable to generate suffix options, or overridden by value of global `al_name_suffixes`.
1135
1136
title_options: (Union[List[str], Callable], optional): Deprecated parameter, use `title_choices` instead. If provided, it will be used to set the title choices.
1137
+
required (Dict[str, bool], optional): A dictionary of field names and if they should be required. Default is None.
1136
1138
1137
1139
Returns:
1138
1140
List[Dict[str, str]]: A list of dictionaries where each dictionary contains field prompt details.
@@ -1196,6 +1198,17 @@ def name_fields(
1196
1198
ifshow_if:
1197
1199
forfieldinfields:
1198
1200
field["show if"] =show_if
1201
+
1202
+
ifmaxlengths:
1203
+
forfieldinfields:
1204
+
iffield["field"] inmaxlengths:
1205
+
field["maxlength"] =maxlengths[field["field"]]
1206
+
1207
+
ifrequired:
1208
+
forfieldinfields:
1209
+
iffield["field"] inrequired:
1210
+
field["required"] =required[field["field"]]
1211
+
1199
1212
returnfields
1200
1213
elifperson_or_business=="business":
1201
1214
fields= [
@@ -1206,6 +1219,17 @@ def name_fields(
1206
1219
]
1207
1220
ifshow_if:
1208
1221
fields[0]["show if"] =show_if
1222
+
1223
+
ifmaxlengths:
1224
+
forfieldinfields:
1225
+
iffield["field"] inmaxlengths:
1226
+
field["maxlength"] =maxlengths[field["field"]]
1227
+
1228
+
ifrequired:
1229
+
forfieldinfields:
1230
+
iffield["field"] inrequired:
1231
+
field["required"] =required[field["field"]]
1232
+
1209
1233
returnfields
1210
1234
else:
1211
1235
# Note: the labels are template block objects: if they are keys,
Generate fields for capturing gender information, including a
@@ -1334,6 +1365,7 @@ def gender_fields(
1334
1365
show_if (Union[str, Dict[str, str], None]): Condition to determine if the field should be shown. Defaults to None.
1335
1366
maxlengths (Dict[str, int], optional): A dictionary of field names and their maximum lengths. Default is None.
1336
1367
choices (Optional[Union[List[Dict[str, str]], Callable]]): A list of choices of genders to use in the prompts, or a callable that returns such a list. Default set of choices includes male, female, nonbinary, prefer-not-to-say, self-described, and unknown.
1368
+
required (Dict[str, bool], optional): A dictionary of field names and if they should be required. Default is None.
1337
1369
1338
1370
Returns:
1339
1371
List[Dict[str, str]]: A list of dictionaries with field prompts for gender.
show_help (bool): Whether to show additional help text. Defaults to False.
1397
1434
show_if (Union[str, Dict[str, str], None]): Condition to determine if the field should be shown. Defaults to None.
1398
-
required (bool): Whether the field is required. Defaults to False.
1435
+
required (Union[bool, Dict[str, bool]]): Whether the field is required. Can be a boolean (applies to all fields) or a dictionary of field names and if they should be required. Defaults to False.
1399
1436
shuffle (bool): Whether to shuffle the order of pronouns. Defaults to False.
1400
1437
show_unknown (Union[Literal["guess"], bool]): Whether to show an "unknown" option. Can be "guess", True, or False. Defaults to "guess".
1401
1438
maxlengths (Dict[str, int], optional): A dictionary of field names and their maximum lengths. Default is None.
@@ -1429,7 +1466,7 @@ def pronoun_fields(
1429
1466
"datatype": "checkboxes",
1430
1467
"choices": shuffled_choices+final_choices,
1431
1468
"none of the above": str(self.pronoun_prefer_not_to_say_label),
0 commit comments