Re: HTML_Quick FORM populating default data

From: Date: Sat, 18 Mar 2006 00:16:56 +0000
Subject: Re: HTML_Quick FORM populating default data
References: 1 2 3 4 5 6 7  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-23335@lists.php.net to get a copy of this message
On 3/17/06, Atif Khan <wequar98@gmail.com> wrote: > Yes, I am using PHP5. Is there an example for cloning ? > I am not familiar with the correct syntax. > > $ClientForm_obj->addGroup(array(clone $areaCode, $phoneNo1, > $phoneNo2), 'w_phone', 'Work Phone:', ' - '); Yes, but clone all 3. $ClientForm_obj->addGroup(array(clone $areaCode, clone $phoneNo1, clone $phoneNo2), 'w_phone', 'Work Phone:', ' - '); > > Thanks again > Atif K > > Justin Patrin wrote: > > On 3/17/06, Atif Khan <wequar98@gmail.com> wrote: > > > >> Here is the HTML source. I cleaned up all the array options so its easier to read. > >> Notice the default I set only for w_phone[areacode], but it populates it on h_phone > >> also. > >> > >> > >> > > > > You're using PHP5 aren't you? In PHP5 Objects are passed by referenced > > by default. This means that you're adding the *same* object instance > > to 2 different groups and that when the areacode is set in one, it's > > set in the other. Use clone() in your addGroup calls around the > > elements. > > > > -- > > Justin Patrin > > > > > -- Justin Patrin

« previous php.pear.general (#23335) next »