From 6e57615ef92b4e06bd04378c159dcbd271c8a5a4 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Sat, 14 Aug 2010 18:45:27 -0400 Subject: [PATCH] Pass only the correct data to each of the owner fields. This fixes the problem of the form failing validation, but it is still broken in the sense that once an owner is set for either of the fields, it is impossible to remove all owners from that field. This is because if the multienum is empty, the default value is applied to it when it is submitted. --- whups/lib/Forms/EditTicket.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/whups/lib/Forms/EditTicket.php b/whups/lib/Forms/EditTicket.php index f1705e668..1e80d443f 100644 --- a/whups/lib/Forms/EditTicket.php +++ b/whups/lib/Forms/EditTicket.php @@ -122,7 +122,16 @@ class EditTicketForm extends Horde_Form { 'multienum', false, false, null, array($f_users)); - $owners->setDefault($whups_driver->getOwners($vars->get('id'))); + $ticketOwners = array(); + $ticketGroups = array(); + foreach($whups_driver->getOwners($vars->get('id')) as $owner) { + if (strpos($owner, 'user:') !== false) { + $ticketOwners[] = $owner; + } else { + $ticketGroups[] = $owner; + } + } + $owners->setDefault($ticketOwners); } if (count($f_groups)) { @@ -133,7 +142,7 @@ class EditTicketForm extends Horde_Form { false, false, null, array($f_groups)); - $group_owners->setDefault($whups_driver->getOwners($vars->get('id'))); + $group_owners->setDefault($ticketGroups); } } break; -- 2.11.0