getFormData() with custom field types?

Hello,

I have created a custom form field using the tutorial found here:
docs.dhtmlx.com/doku.php?id=dhtm … ustom_item

Everything seems to work correctly, except that when I have a custom form field in a form when I call getFormData() on the form, that field is not included in the output.

Do I need to do something special to make that work? I have implemented the getValue method and that works fine.

Any help would be appreciated, I can also provide source code if needed.

Thank you!

Looks like I needed to create a new function that handles the getFormData() call for my custom item like so:

If my custom item’s _type was “myType” it would look like this:

dhtmlXForm.prototype.getFormData_myType = function(name){ return this.doWithItem(name, "getValue"); }

It would be nice if getFormData() and setFormData() used the custom item’s getValue() and setValue() functions by default, thereby eliminating the need to create these wrapper functions.

By the way, the documentation actually says that getFormData() should use the getValue() method by default:

Can you please provide complete demo where getValue() method is not inherited by custom item type?

Olga,

I am trying to point out that getFormData() does not use the custom item’s getValue() function. Here is an example of what I am talking about:

If you go to this page, you will see a dhtmlxForm inside a dhtmlxLayout. The code has a custom dhtmlXForm type named “textList”. There is a form that has a normal “input” field as well as a “textList” field named “myCustomField”.

Add some data to both fields.

When you click on the “Save Changes” button you will see the output of getFormData() in the console, as well as an alert() message showing the result of the getFormData() function looking for the “myCustomField” value.

You will notice that there is no value returned.

If you go to this page you can try the test again, but this time you will get a result.

The difference in the two pages is the addition of the dhtmlXForm.prototype.getFormData_textList function.

According to the documentation I would think that the first test should work fine without the dhtmlXForm.prototype.getFormData_textList function.

Thanks.

I know this probably too late, but i hope this will help others.
I had this problem when i was integrating ckeditor as a custom control, and after going threw source code i found one of 2 solutions.

1- in the render function you add this line of code

    item._type = "ta";

This way the getValue() will do the work.
I really don’t recommend this method the second one is better.

2- in the render function you must add this line of code

    item._type = "youPutHereTheTypeOfYourItem";//Example : ckeditor

Then you after the declaration of you custom item you add this

//In my case "ckeditor" instead of the youPutHereTheTypeOfYourItem
dhtmlXForm.prototype.getFormData_youPutHereTheTypeOfYourItem = function(name){
  return this.doWithItem(name, "getValue");
}

Hope this helps

I really find this quite strange that the documentation says something and the code does another thing, hope this get fixed or the doc changed, because it is really confusing at the first glance.

My bad for not complete reading the docs, but this mislead me.
At this link
http://docs.dhtmlx.com/doku.php?id=dhtmlxform:custom_item
The methods define setting and getting value of the item. Used by setFormData(), getFormData() methods and called while validation: