Index: branches/5.1.x/core/kernel/db/dbitem.php =================================================================== diff -u -N -r13474 -r13545 --- branches/5.1.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 13474) +++ branches/5.1.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 13545) @@ -1,6 +1,6 @@ FieldErrors[$error_field]['pseudo'] = $pseudo; if (isset($error_params)) { + if (array_key_exists('value', $error_params)) { + $this->FieldErrors[$error_field]['value'] = $error_params['value']; + unset($error_params['value']); + } + // additional params, that helps to determine error sources $this->FieldErrors[$error_field]['params'] = $error_params; } @@ -499,7 +504,15 @@ // 2. don't write empty field value to db, when "skip_empty" option is set $field_value = array_key_exists($field_name, $this->FieldValues) ? $this->FieldValues[$field_name] : false; - $skip_empty = array_key_exists('skip_empty', $this->Fields[$field_name]) ? $this->Fields[$field_name]['skip_empty'] : false; + + if (array_key_exists($field_name, $this->Fields)) { + $skip_empty = array_key_exists('skip_empty', $this->Fields[$field_name]) ? $this->Fields[$field_name]['skip_empty'] : false; + } + else { + // field found in database, but not declared in unit config + $skip_empty = false; + } + $skip = $skip || (!$field_value && $skip_empty); // 3. skipping field not in Fields (nor virtual, nor real) @@ -994,30 +1007,14 @@ function PopulateMultiLangFields() { - $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); - /* @var $ml_helper kMultiLanguageHelper */ - - $lang_count = $ml_helper->getLanguageCount(); - foreach ($this->Fields as $field => $options) - { + foreach ($this->Fields as $field => $options) { // master field is set only for CURRENT language - if (isset($options['formatter']) && $options['formatter'] == 'kMultiLanguage' && isset($options['master_field'])) { - if (preg_match('/^l([0-9]+)_(.*)/', $field, $regs)) { - $l = $regs[1]; - $name = $regs[2]; - // MuliLanguage formatter sets error_field to master_field, but in PopulateMlFields mode, we display ML fields directly - // so we set it back to itself, otherwise error will not be displayed - $this->Fields['l' . $l . '_' . $name]['error_field'] = 'l' . $l . '_' . $name; - for ($i = 1; $i <= $lang_count; $i++) { - if ($i == $l || !$ml_helper->LanguageFound($i)) continue; - $f_options = $options; - $f_options['error_field'] = 'l' . $i . '_' . $name; // set error field back to itself - see comment above - if ($i != $this->Application->GetDefaultLanguageId()) { - unset($f_options['required']); // all non-primary language field set to non-required - } - $this->Fields['l' . $i . '_' . $name] = $f_options; - } - } + $formatter = array_key_exists('formatter', $options) ? $options['formatter'] : false; + + if (($formatter == 'kMultiLanguage') && array_key_exists('master_field', $options) && array_key_exists('error_field', $options)) { + // MuliLanguage formatter sets error_field to master_field, but in PopulateMlFields mode, + // we display ML fields directly so we set it back to itself, otherwise error will not be displayed + unset($this->Fields[$field]['error_field']); } } }