LSform/LSformElement : permit form element to provide custom clean value method

This commit is contained in:
Benjamin Renard 2014-11-20 00:18:35 +01:00
parent 881323f813
commit 78d68951e2
3 changed files with 42 additions and 29 deletions

View file

@ -1,6 +1,7 @@
var LSform = new Class({
initialize: function(){
this._modules=[];
this._fields=[];
this._elements=[];
this._tabBtns=[];
@ -176,6 +177,16 @@ var LSform = new Class({
}
},
addField: function(name,obj) {
this._fields[name]=obj;
},
clearFieldValue: function(name) {
if ($type(this._fields[name]) && $type(this._fields[name].clearValue)) {
this._fields[name].clearValue();
}
},
getValue: function(fieldName) {
var retVal = Array();
var inputs = this.getInput(fieldName);

View file

@ -17,7 +17,7 @@ var LSformElement = new Class({
}
elements.each(function(li) {
var id='LSformElement_field_'+this.name+'_'+$random(1,1000);
this.fields[id] = new LSformElement_field(this,li,id);
this.fields[id] = new LSformElement_field(this,li,id,this.name);
}, this);
},

View file

@ -1,8 +1,9 @@
var LSformElement_field = new Class({
initialize: function(LSformElement,li,id){
initialize: function(LSformElement,li,id,field_name){
this.id = id;
this.LSformElement = LSformElement;
this.li = li;
this.field_name = field_name;
if (this.LSformElement.multiple) {
this.addFieldBtn = new Element('img');
@ -36,6 +37,7 @@ var LSformElement_field = new Class({
if ($type(this.getFormField())) {
this.getFormField().value='';
}
varLSform.clearFieldValue(this.field_name);
},
remove: function() {