Index: branches/unlabeled/unlabeled-1.16.2/kernel/include/customfield.php =================================================================== diff -u -r8305 -r8308 --- branches/unlabeled/unlabeled-1.16.2/kernel/include/customfield.php (.../customfield.php) (revision 8305) +++ branches/unlabeled/unlabeled-1.16.2/kernel/include/customfield.php (.../customfield.php) (revision 8308) @@ -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))