diff --git a/src/Controller/TicketController.php b/src/Controller/TicketController.php index 3fcc256e..751b4170 100644 --- a/src/Controller/TicketController.php +++ b/src/Controller/TicketController.php @@ -169,11 +169,11 @@ class TicketController extends BaseController // set autopopulated fields $first_name = $customer->getFirstName(); $last_name = $customer->getLastName(); - $contact_num = false; + $contact_num = ''; $mobile_numbers = $customer->getMobileNumbers(); - if (!empty($mobile_numbers)) { + if (count($mobile_numbers) > 0) { $contact_num = $mobile_numbers[0]->getID(); } } else { @@ -188,7 +188,7 @@ class TicketController extends BaseController // get ticket type $ticket_type = $req->request->get('ticket_type'); - $other_ticket_type = false; + $other_ticket_type = ''; if ($ticket_type == TicketType::OTHER) { $other_ticket_type = $req->request->get('other_ticket_type'); @@ -295,16 +295,10 @@ class TicketController extends BaseController if (empty($customer)) throw $this->createNotFoundException('This customer does not exist'); - // set autopopulated fields - $first_name = $customer->getFirstName(); - $last_name = $customer->getLastName(); - $contact_num = false; - - $mobile_numbers = $customer->getMobileNumbers(); - - if (!empty($mobile_numbers)) { - $contact_num = $mobile_numbers[0]->getID(); - } + // set autopopulated fields to remain the same + $first_name = $obj->getFirstName(); + $last_name = $obj->getLastName(); + $contact_num = $obj->getContactNumber(); } else { // get values directly from form $first_name = $req->request->get('first_name'); @@ -314,7 +308,7 @@ class TicketController extends BaseController // get ticket type $ticket_type = $req->request->get('ticket_type'); - $other_ticket_type = false; + $other_ticket_type = ''; if ($ticket_type == TicketType::OTHER) { $other_ticket_type = $req->request->get('other_ticket_type'); diff --git a/src/Entity/Ticket.php b/src/Entity/Ticket.php index 06e3bfa9..2ed8ac5f 100644 --- a/src/Entity/Ticket.php +++ b/src/Entity/Ticket.php @@ -73,8 +73,7 @@ class Ticket // contact number of ticket owner /** - * @ORM\Column(type="string", length=20) - * @Assert\NotBlank() + * @ORM\Column(type="string", length=20, nullable=true) */ protected $contact_num; diff --git a/templates/ticket/form.html.twig b/templates/ticket/form.html.twig index cfc3b3b7..6cfefd89 100644 --- a/templates/ticket/form.html.twig +++ b/templates/ticket/form.html.twig @@ -40,17 +40,17 @@