Re: Wiki - Configuring dataobject_formbuilder

From: Date: Thu, 01 Jun 2006 12:47:15 +0000
Subject: Re: Wiki - Configuring dataobject_formbuilder
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-24219@lists.php.net to get a copy of this message
Michel D'HOOGE wrote:
I just read the wiki page on configuring DB_FB and wonder if the first example is correct... http://pear.reversefold.com/dokuwiki/doku.php?id=pear:db_dataobject_formbuilder:configuring_formbuilder It is written there that the first method to configure FB is "by setting member variables in an extended class". Then all the other described methods should be able to override these settings. However the constructor is defined as follows: function DB_DataObject_FormBuilder_MyDriver(&$do, $options = false) {
    parent::DB_DataObject_FormBuilder($do, $options);
    $this->linkDispayLevel = 2;
    $this->elementTypeMap['date'] = 'myDate';
} And thus the child class modifies the variables once the parent constructor returns, cancelling any modifications. According to me, the constructor should look like: function DB_DataObject_FormBuilder_MyDriver(&$do, $options = false) {
    $this->linkDispayLevel = 2;
    $this->elementTypeMap['date'] = 'myDate';
    parent::DB_DataObject_FormBuilder($do, $options);
} Any comment? Michel
You have it backwards. If the parent constructor were to be called after local (child) params were set, the parent would over-ride those settings. But this isn't what you would generally want, when extending a class. If you were to do it your way, your child object would be indistinguishable from a parent object (save for any child class methods which might be available). It's early, so perhaps i've missed something here, though. brian

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