Index: branches/RC/core/kernel/db/dbitem.php =================================================================== diff -u -r10576 -r10794 --- branches/RC/core/kernel/db/dbitem.php (.../dbitem.php) (revision 10576) +++ branches/RC/core/kernel/db/dbitem.php (.../dbitem.php) (revision 10794) @@ -835,14 +835,22 @@ $lang_count = $ml_helper->getLanguageCount(); 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]; - unset($options['required']); // all non-primary language field set to non-required - for ($i=1; $i<=$lang_count; $i++) { + // 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; - $this->Fields['l'.$i.'_'.$name] = $options; + $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; } } } Index: branches/RC/core/kernel/utility/formatters/multilang_formatter.php =================================================================== diff -u -r9227 -r10794 --- branches/RC/core/kernel/utility/formatters/multilang_formatter.php (.../multilang_formatter.php) (revision 9227) +++ branches/RC/core/kernel/utility/formatters/multilang_formatter.php (.../multilang_formatter.php) (revision 10794) @@ -89,12 +89,39 @@ { } + */ + /** + * Checks, that field value on primary language is set + * + * @param string $field + * @param mixed $value + * @param Array $options + * @param kDBItem $object + */ function UpdateMasterFields($field, $value, &$options, &$object) { + $master_field = array_key_exists('master_field', $options) ? $options['master_field'] : false; + if (!$master_field) { + return ; + } - }*/ + // moved here from Parse, because at Parse time not all of the fields may be set - this is extremly actual, when working with PopulateMlFields mode + $lang = $this->Application->GetVar('m_lang'); + $def_lang = $this->Application->GetDefaultLanguageId(); + if (!$this->Application->GetVar('allow_translation') && ($lang != $def_lang) && getArrayValue($options, 'required')) { + $def_lang_field = 'l' . $def_lang . '_' . $master_field; + if ( !$object->ValidateRequired($def_lang_field, $options) ) { + $object->SetError($master_field, 'primary_lang_required'); + + if (array_key_exists($def_lang_field, $object->Fields)) { + $object->SetError($def_lang_field, 'primary_lang_required'); + } + } + } + } + function Format($value, $field_name, &$object, $format=null) { $master_field = isset($object->Fields[$field_name]['master_field']) ? $object->Fields[$field_name]['master_field'] : false; @@ -124,18 +151,8 @@ */ function Parse($value, $field_name, &$object) { - $lang = $this->Application->GetVar('m_lang'); - $def_lang = $this->Application->GetDefaultLanguageId(); - $master_field = getArrayValue($object->Fields, $field_name, 'master_field'); - - if (!$this->Application->GetVar('allow_translation') && $lang != $def_lang && getArrayValue($object->Fields, $field_name, 'required')) { - $def_lang_field = 'l'.$def_lang.'_'.$master_field; - if ( !$object->ValidateRequired($def_lang_field, $object->Fields[$field_name]) ) { - $object->SetError($master_field, 'primary_lang_required'); - } - } - if ($value == '') return NULL; + return $value; } } \ No newline at end of file