Re: Re: Using DB_DataOjbect and Quickform together
| From: | Bertrand Mansion | Date: | Thu, 06 Mar 2003 14:29:42 +0000 |
| Subject: | Re: Re: Using DB_DataOjbect and Quickform together | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-4063@lists.php.net to get a copy of this message | ||
<alan@akbkhome.com> wrote :
> It's probably worth wrapping DataObjects and adding a toArray() or a
> toQF() method to the new base class - this may be simpler
>
> function toQF($key) {
> foreach($this->_get_table() as $k=>$v)
> $ret["{$key}[{$k}]"] = $this->$k;
> }
> return $ret;
> }
> myForm = & new UserForm('update', $dataObject->toQuickForm('user'));
Hi Alan,
Maybe a generic toArray() method would be nice ? ;)
Bertrand Mansion
Mamasam
> Regards
> Alan
>
> Demian Turner wrote:
>> Hi,
>>
>> I'm trying to integrate Quickform and DB_DataOjbect for a simple
>> UserManager, the problem is how to feed a DB_DataOjbect object to the
>> setDefaults() method in Quickform, so the form can be pre-populated.
>>
>> The form is setup so all the attributes are elements of the array 'user':
>> user[username]
>> user[password], etc
>>
>> so the whole user entity can be cast to an object easily
>>
>> $oUser = (object)$_POST['user']
>>
>> Any DB_DataOjbect will know this is very handy for updating entities:
>>
>> $modUser->setFrom($oUser);
>>
>> The problem I'm having is that a major transform of the entity is
>> necessary to get it into a format compantible with QF. Apologies in
>> advance for the following code, there's probably an easier way of doing
>> this ;-)
>>
>> The question is, is there any interest in creating a
>> setDefaultsFromDataObject() method in Quickform? Two such great
>> packages it seems a shame not to use them in conjunction.
>>
>> cheers,
>>
>> Demian