LSformElement_text : use getValue/getInput of LSform object instead of LSformElement_text to permit value generation with more form element type

This commit is contained in:
Benjamin Renard 2014-06-17 17:33:03 +02:00
parent e58be43126
commit 11e4705740
2 changed files with 7 additions and 19 deletions

View file

@ -51,14 +51,6 @@ var LSformElement_text = new Class({
} }
} }
return retval; return retval;
},
getInput: function(name) {
return this.elements[name][0].getInput();
},
getValue: function(name) {
return this.elements[name][0].getValue();
} }
}); });

View file

@ -42,8 +42,12 @@ var LSformElement_text_field = new Class({
if (((this.isCreation)&&(this.params.autoGenerateOnCreate))||(force)) { if (((this.isCreation)&&(this.params.autoGenerateOnCreate))||(force)) {
this.dependsFields = this.parent.getDependsFields(this.format); this.dependsFields = this.parent.getDependsFields(this.format);
this.dependsFields.each(function(el) { this.dependsFields.each(function(el) {
var input = this.parent.getInput.bind(this.parent)(el); var inputs = varLSform.getInput.bind(this.parent)(el);
input.addEvent('change',this.refreshValue.bind(this)); if (inputs.lenght>0) {
inputs.each(function(input) {
input.addEvent('change',this.refreshValue.bind(this));
},this);
}
},this); },this);
} }
this._start=true; this._start=true;
@ -51,20 +55,12 @@ var LSformElement_text_field = new Class({
} }
}, },
getInput: function() {
return this.input;
},
getValue: function() {
return this.input.value;
},
refreshValue: function(force) { refreshValue: function(force) {
if (force==true) { if (force==true) {
this._auto=1; this._auto=1;
} }
if (((this._auto)||(force==true))&&((this.generatedValue=="")||(this.generatedValue==this.input.value)||(force==true))) { if (((this._auto)||(force==true))&&((this.generatedValue=="")||(this.generatedValue==this.input.value)||(force==true))) {
var val=getFData(this.format,this.parent,'getValue'); var val=getFData(this.format,varLSform,'getValue');
if ($type(this.params['withoutAccent'])) { if ($type(this.params['withoutAccent'])) {
if(this.params['withoutAccent']) { if(this.params['withoutAccent']) {
val = replaceAccents(val); val = replaceAccents(val);