Index: trunk/kernel/include/customfield.php =================================================================== diff -u -N -r7635 -r8397 --- trunk/kernel/include/customfield.php (.../customfield.php) (revision 7635) +++ trunk/kernel/include/customfield.php (.../customfield.php) (revision 8397) @@ -24,7 +24,16 @@ $a->heading = $this->Get("Heading"); $a->prompt = $this->Get("Prompt"); $a->ElementType = $this->Get("ElementType"); - $a->ValidationRules=""; + + $main_prefix = $this->getMainPrefix($this->Get('Type')); + $fields = $this->Application->getUnitOption($main_prefix, 'Fields'); + if (isset($fields['cust'.$a->name]['required']) && $fields['cust'.$a->name]['required']) { + $a->ValidationRules = 'exists'; + } + else { + $a->ValidationRules = ''; + } + $a->default_value = ""; $a->ValueList=$this->Get("ValueList"); if(!strlen($a->ElementType)) @@ -34,6 +43,18 @@ return $a; } + function getMainPrefix($item_type) + { + static $main_prefixes = null; + if (!isset($main_prefixes)) { + $sql = 'SELECT Prefix, ItemType + FROM '.TABLE_PREFIX.'ItemTypes'; + $main_prefixes = $this->Conn->GetCol($sql, 'ItemType'); + } + + return $main_prefixes[$item_type]; + } + function parsetag($tag) { if(is_object($tag)) @@ -104,7 +125,8 @@ function LoadFieldsAndValues($ResourceId, $main_prefix, $temp_table = false) { $this->Clear(); - + + $this->Application->getUnitOption($main_prefix, 'TableName'); $table = $this->Application->getUnitOption($main_prefix.'-cdata', 'TableName'); if ($temp_table) { $table = $this->Application->GetTempName($table, 'prefix:'.$main_prefix);