Re: Reusable form elements with DB_Table and HTML_Quickforms
| From: | Mark Wiesemann | Date: | Tue, 17 Oct 2006 09:59:35 +0000 |
| Subject: | Re: Reusable form elements with DB_Table and HTML_Quickforms | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25479@lists.php.net to get a copy of this message | ||
Hi Matthew,
Matthew Vickery wrote:
> It would be great if I could define a pool of reusable form elements
> and then include or merge these into several form/database schemas.
Your idea seems to be good, but the code in the Guestbook is not valid.
> class Guestbook extends DB_Table {
>
> var $col = array_merge(
> $id,
> $personal_details
> );
>
> }
You can't use array_merge() here. A solution would be use
var $col = array();
instead and move the array_merge() call into the constructor, like this:
function Guestbook(&$db, $table, $create = false)
{
$this->col = array_merge(
Elements_Pool::id,
Elements_Pool::personal_details
);
parent::DB_Table($db, $table, $create);
}
(not tested, but you should get the idea)
Regards,
Mark