From 3fcb3d31b5d2063fdce5a696932f40aead7be34e Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 7 Jul 2020 07:34:43 +0000 Subject: [PATCH] Limit customer vehicles to 2 per customer. #434 --- templates/customer/cmb.form.html.twig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/templates/customer/cmb.form.html.twig b/templates/customer/cmb.form.html.twig index e417f3bb..c979b7d7 100644 --- a/templates/customer/cmb.form.html.twig +++ b/templates/customer/cmb.form.html.twig @@ -663,9 +663,18 @@ // display create vehicle form $("#add-vehicle").click(function() { - $("#vehicle-form").data('mode', 'create'); - $("#vehicle-form-title").html("Add Vehicle"); - $("#vehicle-form-modal").modal('show'); + // check if there are already 2 vehicles in list + if (vehicleRows.length == 2) + { + swal({ + text: 'Customer is limited to only 2 vehicles..', + type: 'info', + }); + } else { + $("#vehicle-form").data('mode', 'create'); + $("#vehicle-form-title").html("Add Vehicle"); + $("#vehicle-form-modal").modal('show'); + } }); // find vehicle row by index