/**
  * Overrides set() to check that the type field is not being set improperly
  *
  * @param array $pa_fields
  * @param mixed $pm_value
  * @param array $pa_options Options are passed directly to parent::set(); options specifically defined here are:
  *		allowSettingOfTypeID = if true then type_id may be set for existing rows; default is to not allow type_id to be set for existing rows.
  */
 public function set($pa_fields, $pm_value = "", $pa_options = null)
 {
     if (!is_array($pa_fields)) {
         $pa_fields = array($pa_fields => $pm_value);
     }
     if (($vs_type_list_code = $this->getTypeListCode()) && ($vs_type_field_name = $this->getTypeFieldName())) {
         if (isset($pa_fields[$vs_type_field_name]) && !is_numeric($pa_fields[$vs_type_field_name])) {
             if ($vn_id = ca_lists::getItemID($vs_type_list_code, $pa_fields[$vs_type_field_name])) {
                 $pa_fields[$vs_type_field_name] = $vn_id;
             }
         }
     }
     if ($this->getPrimaryKey() && !$this->isRelationship() && isset($pa_fields[$this->getTypeFieldName()]) && !(isset($pa_options['allowSettingOfTypeID']) && $pa_options['allowSettingOfTypeID'])) {
         $this->postError(2520, _t("Type id cannot be set after insert"), "BundlableLabelableBaseModelWithAttributes->set()", $this->tableName() . '.' . $this->getTypeFieldName());
         return false;
     }
     if ($this->opo_idno_plugin_instance) {
         // If attempting to set parent_id, then flag record as child for id numbering purposes
         $this->opo_idno_plugin_instance->isChild(($vs_parent_id_fld = $this->getProperty('HIERARCHY_PARENT_ID_FLD')) && isset($pa_fields[$vs_parent_id_fld]) && $pa_fields[$vs_parent_id_fld] > 0 || $this->get($vs_parent_id_fld) ? true : false);
         if (in_array($this->getProperty('ID_NUMBERING_ID_FIELD'), $pa_fields)) {
             if (!$this->_validateIncomingAdminIDNo(true, true)) {
                 if (!$this->get($vs_parent_id_fld) && isset($pa_fields[$vs_parent_id_fld]) && $pa_fields[$vs_parent_id_fld] > 0) {
                     // If we failed to set parent_id and there wasn't a parent_id set already then revert child status in id numbering
                     $this->opo_idno_plugin_instance->isChild(false);
                 }
                 return false;
             }
         }
     }
     if ($vn_rc = parent::set($pa_fields, "", $pa_options)) {
         // Set type for idno purposes
         if (in_array($vs_type_field_name = $this->getTypeFieldName(), $pa_fields) && $this->opo_idno_plugin_instance) {
             $this->opo_idno_plugin_instance->setType($this->getTypeCode());
         }
     }
     return $vn_rc;
 }