diff --git a/geocity/apps/forms/admin.py b/geocity/apps/forms/admin.py index fbd9e4bca..d7396111b 100644 --- a/geocity/apps/forms/admin.py +++ b/geocity/apps/forms/admin.py @@ -556,6 +556,22 @@ def clean_maximum_date(self): return maximum_date + def clean_map_widget_configuration(self): + selected_input_type = self.cleaned_data.get("input_type") + map_widget_configuration = self.cleaned_data.get("map_widget_configuration") + + if ( + selected_input_type == models.Field.INPUT_TYPE_GEOM + and not map_widget_configuration + ): + raise forms.ValidationError( + _( + "Vous devez obligatoirement sélectionner une configuration de carte avancée." + ) + ) + + return map_widget_configuration + class Media: js = ("js/admin/form_field.js",)