From e2db2ae6f475370ad822ee04281d2a3ae70cfc69 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 12 Dec 2013 22:11:27 -0600 Subject: [PATCH] Fix regression displaying errors on ticket form --- include/client/open.inc.php | 8 ++++++-- include/staff/ticket-open.inc.php | 6 ++++-- scp/tickets.php | 13 ++----------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/include/client/open.inc.php b/include/client/open.inc.php index c5ecb42c6..d47e07380 100644 --- a/include/client/open.inc.php +++ b/include/client/open.inc.php @@ -40,14 +40,18 @@ $info=($_POST && $errors)?Format::htmlchars($_POST):$info; </tr> <?php if (!$thisclient) { - UserForm::getUserForm()->render(false, 'Your Information'); + $uform = UserForm::getUserForm()->getForm($_POST); + if ($_POST) $uform->isValid(); + $uform->render(false, 'Your Information'); } else { ?> <tr><td colspan="2"><hr /></td></tr> <tr><td>Email:</td><td><?php echo $thisclient->getEmail(); ?></td></tr> <tr><td>Client:</td><td><?php echo $thisclient->getName(); ?></td></tr> <?php } - TicketForm::getInstance()->render(false); ?> + $tform = TicketForm::getInstance()->getForm($_POST); + if ($_POST) $tform->isValid(); + $tform->render(false); ?> </tbody> <tbody id="dynamic-form"> <?php if ($form) { diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 1c49b4073..8d5ce5b55 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -222,12 +222,14 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </tr> <?php } - TicketForm::getInstance()->render(true); + $tform = TicketForm::getInstance()->getForm($_POST); + if ($_POST) $tform->isValid(); + $tform->render(true); ?> </tbody> <tbody id="dynamic-form"> <?php - if ($form) $form->render(true); + if ($form) $form->getForm()->render(true); ?> </tbody> <tbody> diff --git a/scp/tickets.php b/scp/tickets.php index 32b82768e..f28ac8e3e 100644 --- a/scp/tickets.php +++ b/scp/tickets.php @@ -471,20 +471,11 @@ if($_POST && !$errors): break; case 'open': $ticket=null; - $interest=array('name','email','subject'); if ($topic=Topic::lookup($_POST['topicId'])) { if ($form = DynamicForm::lookup($topic->ht['form_id'])) { $form = $form->instanciate(); - # Collect name, email, and subject address for banning and such - foreach ($form->getAnswers() as $answer) { - $fname = $answer->getField()->get('name'); - if (in_array($fname, $interest)) - # XXX: Assigning to _POST not considered great PHP - # coding style - $_POST[$fname] = $answer->getField()->getClean(); - } - if (!$form->isValid()) - $errors = array_merge($errors, $form->errors()); + if (!$form->getForm()->isValid()) + $errors = array_merge($errors, $form->getForm()->errors()); } } if(!$thisstaff || !$thisstaff->canCreateTickets()) { -- GitLab