Merge pull request #4 from vincentmdealmeida/ValidationV2.1
Fixed a validation error where the form wouldn't validate after the d…
This commit is contained in:
commit
6b70b01e06
3 changed files with 28 additions and 8 deletions
|
@ -304,7 +304,14 @@ def create_event(request):
|
||||||
demo_users = DemoUser.objects.all()
|
demo_users = DemoUser.objects.all()
|
||||||
|
|
||||||
# Render the template
|
# Render the template
|
||||||
return render(request, "polls/create_event.html", {"G_R_SITE_KEY": settings.RECAPTCHA_PUBLIC_KEY, "user_email": request.user.email, "events": events, "demo_users": demo_users})
|
return render(request,
|
||||||
|
"polls/create_event.html",
|
||||||
|
{
|
||||||
|
"G_R_SITE_KEY": settings.RECAPTCHA_PUBLIC_KEY,
|
||||||
|
"user_email": request.user.email,
|
||||||
|
"events": events,
|
||||||
|
"demo_users": demo_users
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
return HttpResponseNotAllowed()
|
return HttpResponseNotAllowed()
|
||||||
|
|
||||||
|
|
|
@ -133,9 +133,9 @@
|
||||||
<th class="text-center">Actions</th>
|
<th class="text-center">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="sort" class="formset option-formset" data-formset-prefix="questions" data-formset-type="inline">
|
<tbody id="sort" class="formset option-formset" data-formset-prefix="options" data-formset-type="inline">
|
||||||
<!-- Option -->
|
<!-- Option -->
|
||||||
<tr class="formset-form sorting-row" data-formset-form-prefix="question">
|
<tr class="formset-form sorting-row" data-formset-form-prefix="option">
|
||||||
<!-- # -->
|
<!-- # -->
|
||||||
<th class="formset-form-index text-center" scope=row>
|
<th class="formset-form-index text-center" scope=row>
|
||||||
1
|
1
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Option -->
|
<!-- Option -->
|
||||||
<tr class="formset-form sorting-row" data-formset-form-prefix="question">
|
<tr class="formset-form sorting-row" data-formset-form-prefix="option">
|
||||||
<!-- # -->
|
<!-- # -->
|
||||||
<th class="formset-form-index text-center" scope=row>
|
<th class="formset-form-index text-center" scope=row>
|
||||||
2
|
2
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Option -->
|
<!-- Option -->
|
||||||
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="question">
|
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="option">
|
||||||
<!-- # -->
|
<!-- # -->
|
||||||
<th class="formset-form-index text-center" scope=row>
|
<th class="formset-form-index text-center" scope=row>
|
||||||
X
|
X
|
||||||
|
@ -197,7 +197,7 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<button type="button" class="btn btn-primary formset-add" data-formset-prefix="questions">
|
<button type="button" class="btn btn-primary formset-add" data-formset-prefix="options">
|
||||||
<i class="fa fa-plus-circle" aria-hidden="true"></i>
|
<i class="fa fa-plus-circle" aria-hidden="true"></i>
|
||||||
Add Question Option
|
Add Question Option
|
||||||
</button>
|
</button>
|
||||||
|
@ -268,7 +268,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Organiser -->
|
<!-- Organiser -->
|
||||||
<tr class="formset-form sorting-row" data-formset-form-prefix="question">
|
<tr class="formset-form sorting-row" data-formset-form-prefix="organiser">
|
||||||
<th class="formset-form-index text-center" scope=row>
|
<th class="formset-form-index text-center" scope=row>
|
||||||
<!-- # -->
|
<!-- # -->
|
||||||
2
|
2
|
||||||
|
@ -287,7 +287,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Organiser -->
|
<!-- Organiser -->
|
||||||
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="question">
|
<tr class="formset-form sorting-row formset-form-empty hidden" data-formset-form-prefix="organiser">
|
||||||
<th class="formset-form-index text-center" scope=row>
|
<th class="formset-form-index text-center" scope=row>
|
||||||
<!-- # -->
|
<!-- # -->
|
||||||
X
|
X
|
||||||
|
|
|
@ -832,4 +832,17 @@ $('.formset-form-remove').click(function (e) { // Ported from DEMOS1
|
||||||
}
|
}
|
||||||
updateFormset(formset);
|
updateFormset(formset);
|
||||||
formset.trigger('formsetFormRemoved');
|
formset.trigger('formsetFormRemoved');
|
||||||
|
|
||||||
|
// Perform validation now that a row has been removed
|
||||||
|
switch (formPrefix) {
|
||||||
|
case 'option':
|
||||||
|
validateFormField(isPollOptionsValid, "options-input-error-block");
|
||||||
|
break;
|
||||||
|
case 'organiser':
|
||||||
|
validateFormField(areOrganisersEmailsValid, "organisers-input-error-block");
|
||||||
|
break;
|
||||||
|
case 'trustee':
|
||||||
|
validateFormField(areTrusteesEmailsValid, "trustees-input-error-block");
|
||||||
|
break;
|
||||||
|
}
|
||||||
});
|
});
|
Reference in a new issue