From 285113542ba36fbc197fc9f216e06050ff59f632 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 25 Apr 2014 09:46:53 -0500 Subject: [PATCH] forms: Permit clone()ing a FormField The `id` needs to be changed for the new clone in order for the POST data to line up with with new field --- include/class.forms.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/class.forms.php b/include/class.forms.php index 4eeed67e7..add154b01 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -146,12 +146,17 @@ class FormField { ), ); static $more_types = array(); + static $uid = 100; function __construct($options=array()) { - static $uid = 100; $this->ht = array_merge($this->ht, $options); if (!isset($this->ht['id'])) - $this->ht['id'] = $uid++; + $this->ht['id'] = self::$uid++; + } + + function __clone() { + $this->_widget = null; + $this->ht['id'] = self::$uid++; } static function addFieldTypes($group, $callable) { -- GitLab