mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-06 01:19:00 -04:00
Swap order of move_to validators
If Optional runs before required_for_ops, it stops the validation chain so it doesn't get to required_for_ops. The move_to field isn't required for the 'move-to-new-folder' operation, so this has been removed. This also adds comments explaining why we set default to an empty string when instantiating the move_to field.
This commit is contained in:
@@ -1285,12 +1285,15 @@ class TemplateAndFoldersSelectionForm(Form):
|
||||
templates_and_folders = MultiCheckboxField('Choose templates or folders', validators=[
|
||||
required_for_ops('move-to-new-folder', 'move-to-existing-folder')
|
||||
])
|
||||
# if no default set, it is set to None, which process_data transforms to '__NONE__'
|
||||
# this means '__NONE__' (self.ALL_TEMPLATES option) is selected when no form data has been submitted
|
||||
# set default to empty string so process_data method doesn't perform any transformation
|
||||
move_to = NestedRadioField(
|
||||
'Choose a folder',
|
||||
default='',
|
||||
validators=[
|
||||
Optional(),
|
||||
required_for_ops('move-to-new-folder', 'move-to-existing-folder')
|
||||
required_for_ops('move-to-existing-folder'),
|
||||
Optional()
|
||||
])
|
||||
add_new_folder_name = StringField('Folder name', validators=[required_for_ops('add-new-folder')])
|
||||
move_to_new_folder_name = StringField('Folder name', validators=[required_for_ops('move-to-new-folder')])
|
||||
|
||||
Reference in New Issue
Block a user