summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chimere/forms.py7
-rw-r--r--chimere/templates/chimere/edit.html8
2 files changed, 11 insertions, 4 deletions
diff --git a/chimere/forms.py b/chimere/forms.py
index 965c93c..adf8687 100644
--- a/chimere/forms.py
+++ b/chimere/forms.py
@@ -272,6 +272,7 @@ def get_properties(queryset):
fields = collections.OrderedDict()
for prop in queryset:
key = "property_%d_%d" % (prop.order, prop.id)
+ required = prop.mandatory
if prop.type == 'C':
choices = PropertyModelChoice.objects.filter(propertymodel=prop,
available=True
@@ -279,17 +280,17 @@ def get_properties(queryset):
fields[key] = forms.ChoiceField(
label=prop.name, choices=[('', '--')] +
[(choice.pk, str(choice)) for choice in choices],
- required=False)
+ required=required)
elif prop.type == 'A':
widget = PropertyModel.TYPE_WIDGET[prop.type]
widget = widget(slug=prop.slug)
fields[key] = forms.CharField(label=prop.name, widget=widget,
- required=False)
+ required=required)
else:
widget = PropertyModel.TYPE_WIDGET[prop.type]
fields[key] = forms.CharField(
label=prop.name, widget=widget,
- required=False)
+ required=required)
return fields
diff --git a/chimere/templates/chimere/edit.html b/chimere/templates/chimere/edit.html
index 129097f..9e2ab9b 100644
--- a/chimere/templates/chimere/edit.html
+++ b/chimere/templates/chimere/edit.html
@@ -190,10 +190,14 @@
if (typeof tinyMCE !== 'undefined') tinyMCE.triggerSave();
validation = [
'{% if geom_name == 'marker' %}point{% else %}{{geom_name}}{% endif %}',
- 'name',
'categories',{% if event %}
'start_date',{% endif %}
];
+
+ $("input[required]").each(function(){
+ validation.push($(this).attr('name'));
+ });
+
var validated = true;
for (var idx=0; idx<validation.length ;idx++){
var input_id = validation[idx];
@@ -212,6 +216,8 @@
}
if (!validated){
alert("{%trans "There are missing/erroneous fields."%}");
+ $('#modal-edit').animate(
+ { scrollTop: 0 }, 'fast');
return false;
}
$("#proposition_form").ajaxForm();