I try to create own formfield type as this:
var myForm,myPop;
dhtmlXForm.prototype.items.myType = {
render: function(item, data) {
item._type = “myType”;
item._enabled = true;
this.doAddLabel(item, data);
this.doAddInput(item, data,‘INPUT’,‘TEXT’,true,true,“dhxform_textarea”);
this.doAttachEvents(item);
return this;
}
};
(function(){
for (var a in {doAddLabel:1,doAddInput:1,doAttachEvents:1,destruct:1,doUnloadNestedLists:1,setText:1,getText:1,setValue:1,getValue:1,updateValue:1,enable:1,disable:1,isEnabled:1,setWidth:1,setReadonly:1,isReadonly:1,setFocus:1,getInput:1})
dhtmlXForm.prototype.items.myType[a] = dhtmlXForm.prototype.items.input[a];
})();
function doOnLoad() {
formData = [
{type:“settings”,position:“label-left”,labelWidth: 160,labelAlign:‘right’},
{type: “fieldset”,name:“calculator”, label: “calculations”, list:[
{type: “myType”, name: “myField”, label: “First field”},
{type: “input”, name: ‘dxNum’, value:100, label: ‘First number’}
{type: “input”, name: ‘other’, value:200, label: ‘Other field’}
]
myForm = new dhtmlXForm(“form_container”, formData);
myPop = new dhtmlXPopup({ form: myForm, id: [‘myField’,‘dxNum’]});
myPop.attachHTML(“Please enter something
Second line
One more line here”);
myForm.attachEvent(“onFocus”, function(id,value){
if(id==‘myType’) myPop.show(id);
else doSomething();
});
myForm.attachEvent(“onBlur”, function(id,value){
if(id==‘myType’) myPop.hide();
});
}
But Popup doesn’t work.
If I change field name for popup, it work correctly
Why