Ferreteria/v0.3/class/tMakableFieldRow

From Woozle Writes Code
< Ferreteria‎ | v0.3‎ | class
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;
    }
}