Index: branches/RC/core/admin_templates/js/form_controls.js =================================================================== diff -u -r10673 -r11283 --- branches/RC/core/admin_templates/js/form_controls.js (.../form_controls.js) (revision 10673) +++ branches/RC/core/admin_templates/js/form_controls.js (.../form_controls.js) (revision 11283) @@ -14,13 +14,15 @@ this.InEditing = false; } -MultiInputControl.prototype.registerControl = function($field_name, $type, $required) { - this.Controls[$field_name] = {'type' : $type, 'required' : $required}; +MultiInputControl.prototype.registerControl = function($field_name, $type, $required, $options) { + this.Controls[$field_name] = {'type' : $type, 'required' : $required, 'options' : $options}; } -MultiInputControl.prototype.getControl = function ($field, $appendix) { +MultiInputControl.prototype.getControl = function ($field, $appendix, $prepend) { $appendix = isset($appendix) ? '_' + $appendix : ''; - return document.getElementById( this.FieldMask.replace('#FIELD_NAME#', $field) + $appendix ); + $prepend = isset($prepend) ? $prepend + '_' : ''; + + return document.getElementById( $prepend + this.FieldMask.replace('#FIELD_NAME#', $field) + $appendix ); } MultiInputControl.prototype.getControlValue = function ($field) { @@ -61,6 +63,11 @@ } break; + case 'checkbox': + this.getControl($field).value = ($value === null) ? 0 : $value; + this.getControl($field, null, '_cb').checked = parseInt($value) == 1; + break; + /*case 'datetime': $value = $value.split(' '); this.getControl($field + '_date').value = $value[0]; @@ -87,6 +94,17 @@ } + if (this.Controls[$field]['type'] == 'textbox') { + var $field_options = this.Controls[$field]['options']; + if ($field_options && parseInt($field_options.first_chars) > 0) { + $value = $value.substring(0, parseInt($field_options.first_chars)); + } + } + + if (this.Controls[$field]['type'] == 'checkbox') { + $value = this.Controls[$field]['options'][ parseInt($value) ]; + } + return $value; } @@ -235,7 +253,8 @@ } else if ($child.tagName == 'field') { if ($root_name == 'records') { - this.Records[this.Records.length - 1][$child.getAttribute('name')] = $child.firstChild.nodeValue; + // no firstChild, when node value is empty! + this.Records[this.Records.length - 1][$child.getAttribute('name')] = $child.firstChild ? $child.firstChild.nodeValue : ''; } else if ($root_name == 'errors') { this.Errors[$child.getAttribute('name')] = $child.firstChild.nodeValue;