public function set($fieldname, $value) { if (!$this->type_table OR ! count($this->type_fields) or ! isset($this->type_fields[$fieldname]) ) { return parent::set($fieldname, $value); } //if we got here, we're validating a type-specific field. $error = false; if (false === $value) { $value = ''; } if (false === ($value = $this->validateTypeField($fieldname, $value, $error))) { if ($this->strict) { throw (new vB_Exception_DM('Value given to set DM \'' . get_class($this) . '\' field \'' . hmtlspecialchars($fieldname) . '\' is not valid: ' . $error)); } $this->error($error, $fieldname); } if ($fieldname == 'contentid') { //no more checking. $this->type_set_fields['contentid'] = $value; } else { if (self::REQ_AUTO == $this->type_fields[$fieldname][self::VF_REQ]) { throw (new vB_Exception_DM('Cannot set the value of automatic field \'' . htmlspecialchars($fieldname) . '\' in DM \'' . get_class($this) . '\'')); } $this->type_set_fields[$fieldname] = $value; } }
/** * Sets a field. * The field is always validated before being set. If any transformation is * required, then this method should be overridden. * * @param string $fieldname - The name of the field to set * @param mixed $value - The value to set */ public function set($fieldname, $value) { if (false === $value) { $value = ''; } $error = false; if (false === ($value = $this->validate($fieldname, $value, $error))) { if ($this->strict) { throw new vB_Exception_DM('Value given to set DM \'' . get_class($this) . '\' field \'' . hmtlspecialchars($fieldname) . '\' is not valid: ' . $error); } $this->error($error, $fieldname); } if (self::REQ_AUTO == $this->fields[$fieldname][self::VF_REQ]) { throw new vB_Exception_DM('Cannot set the value of automatic field \'' . htmlspecialchars_uni($fieldname) . '\' in DM \'' . get_class($this) . '\''); } $this->setField($fieldname, $value); }