Ferreteria/v0.3/class/tMakableFieldRow

From Woozle Writes Code
< Ferreteria‎ | v0.3‎ | class
Revision as of 16:43, 22 May 2022 by Woozle (talk | contribs) (6 revisions imported: moving this project here)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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;
    }
}