Commit ae99af36 authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

expand the 'advanced' tab in case of server-side validation error

parent d630d502
Pipeline #53083 failed with stage
in 1 minute and 22 seconds
......@@ -142,6 +142,8 @@ class WebappForm(forms.ModelForm):
# Advanced
ADVANCED_FIELDS = ("docker_os", "memory_limit_mb", "job_queue",
"entrypoint", "owner", "tags")
docker_os = forms.ModelChoiceField(
label='Operating sytem',
......@@ -227,6 +227,11 @@ class WebappUpdate(SuccessMessageMixin, LoginRequiredMixin, UpdateView):
def get_context_data(self, **kwargs):
ctx["action"] = "Update"
# we expand the 'advanced' tab if any of its field has a validation error
ctx["show_advanced"] = bool(set(ctx["form"].errors)
return ctx
def get_form(self):
......@@ -287,6 +292,7 @@ class WebappCreate(SuccessMessageMixin, LoginRequiredMixin, IsProviderMixin, Cre
def get_context_data(self, **kwargs):
ctx["action"] = "Create"
ctx["show_advanced"] = False
return ctx
def form_valid(self, form):
......@@ -66,12 +66,12 @@
<div class="card">
<div class="card-header">
<h5 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseAdvanced" aria-expanded="false" aria-controls="collapseAdvanced">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseAdvanced" aria-expanded="{{show_advanced}}" aria-controls="collapseAdvanced">
Advanced options
<div class="collapse" id="collapseAdvanced">
<div class="collapse {% if show_advanced %}show{% endif %}" id="collapseAdvanced">
<div class="card-body">
<div class="form-row">
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment