Ferreteria/v0.3/class/tMakableFieldRow: Difference between revisions

From Woozle Writes Code
< Ferreteria‎ | v0.3‎ | class
Jump to navigation Jump to search
m (Woozle moved page Ferreteria/class/cMakableFieldRow to Ferreteria/class/tMakableFieldRow: needs to be a trait)
m (6 revisions imported: moving this project here)
 
(3 intermediate revisions by one other user not shown)
Line 2: Line 2:
<source lang=php>
<source lang=php>
// PURPOSE: adds functionality to create fields as needed
// PURPOSE: adds functionality to create fields as needed
abstract class cMakableFieldRow extends cFieldRow implements ifDataDesign {
trait tMakableFieldRow {
 
     /*----
     /*----
       PURPOSE: sets an individual value
       PURPOSE: sets an individual value
Line 27: Line 26:
</source>
</source>
* '''file''': {{l/ferreteria/file|data/rows/base.php}}
* '''file''': {{l/ferreteria/file|data/rows/base.php}}
* '''extends''': {{l/ferreteria/class|cFieldRow}}
* '''apply to''': {{l/ferreteria/class|cFieldRow}}
* '''implements''': {{l/ferreteria/class|ifDataDesign}}
* '''implements''': {{l/ferreteria/class|ifDataDesign}}
* '''extended by''':
* '''used by''':
** {{l/ferreteria/class|cMemoryRow}}
** {{l/ferreteria/class|cMemoryRow}}
** {{l/ferreteria/class|cStandardRow}}

Latest revision as of 16:43, 22 May 2022

Template:Page/code/class

// PURPOSE: adds functionality to create fields as needed
trait tMakableFieldRow {
    /*----
      PURPOSE: sets an individual value
      OVERRIDE: will create Field object if not set
    */
    public function SetValue($sKey, $val) {
        $oField = $this->MakeField($sKey);
        $oField->SetValue($val);
    }
    protected function MakeField($sKey) {
        $oField = NULL;
        if ($this->FieldIsSet($sKey)) {
            $oField = $this->RetrieveField($sKey);
        }
        if (is_null($oField)) {
            $sClass = $this->GetClass_forField($sKey);
            $oField = new $sClass($sKey,$this);
            $this->SetField($oField);
        }
        return $oField;
    }
}