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/tMakableFieldRow to Ferreteria/v3/class/tMakableFieldRow without leaving a redirect: this is all v3 documentation, and we still need v2)
m (6 revisions imported: moving this project here)
 
(One intermediate revision by one other user not shown)
(No difference)

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