mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Add some handling to allow ID to be different from the value source by allowing the value attribute to point to the value.
This commit is contained in:
parent
0eb14c1dc1
commit
b1e77ca062
@ -66,10 +66,10 @@ abstract class etemplate_widget_entry extends etemplate_widget_transformer
|
||||
$attrs['id'] = $this->id;
|
||||
|
||||
$form_name = self::form_name($cname, $this->id);
|
||||
$data_id = $this->value ? self::form_name($cname, $this->value) : self::form_name($cname, self::ID_PREFIX . $this->id);
|
||||
|
||||
$data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX . $this->id);
|
||||
|
||||
// No need to proceed
|
||||
if(!$this->id) return;
|
||||
if(!$data_id) return;
|
||||
|
||||
// Find out which record to load
|
||||
$value = self::get_array(self::$request->content, $form_name, false, true);
|
||||
@ -89,7 +89,7 @@ abstract class etemplate_widget_entry extends etemplate_widget_transformer
|
||||
// Check for conflict - more than one with same id/field and different type
|
||||
if($old_type && $old_type != $this->type)
|
||||
{
|
||||
self::set_validation_error($this->id, lang('%1, duplicate ID', $this));
|
||||
//self::set_validation_error($this->id, lang('%1, duplicate ID', $this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,13 +71,20 @@ var et2_entry = et2_valueWidget.extend(
|
||||
*/
|
||||
init: function(parent, attrs) {
|
||||
// Often the ID conflicts, so check prefix
|
||||
if(attrs.id && attrs.id.indexOf(this.prefix) < 0 && typeof attrs.value == 'undefined')
|
||||
if(attrs.id && attrs.id.indexOf(this.prefix) < 0)
|
||||
{
|
||||
attrs.id = this.prefix + attrs.id;
|
||||
}
|
||||
var value = attrs.value;
|
||||
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
// Save value from parsing, but only if set
|
||||
if(value)
|
||||
{
|
||||
this.options.value = value;
|
||||
}
|
||||
|
||||
this.widget = null;
|
||||
this.setDOMNode(document.createElement('span'));
|
||||
},
|
||||
@ -108,9 +115,15 @@ var et2_entry = et2_valueWidget.extend(
|
||||
};
|
||||
var widget = et2_createWidget(attrs.type, attrs, this);
|
||||
|
||||
// If value is not set, etemplate takes care of everything
|
||||
// If value was set, find the record explicitly.
|
||||
if(typeof this.options.value == 'string')
|
||||
{
|
||||
widget.options.value = this.getRoot().getArrayMgr('content').getEntry(this.prefix+this.options.value + '['+this.options.field+']');
|
||||
}
|
||||
if(this.options.compare)
|
||||
{
|
||||
widget.options.value = this.getArrayMgr('content').getEntry(this.options.field) == this.options.compare ? 'X' : '';
|
||||
widget.options.value = widget.options.value == this.options.compare ? 'X' : '';
|
||||
}
|
||||
if(this.options.alternate_fields)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user