Custom form control function

I have followed the tut here:
http://docs.dhtmlx.com/touch/doku.php?id=how_to_create_a_new_form_control
with a couple modifications and I can’t get the setValue() function to work properly. Here is the custom form render:

return "<input name='sig' value='"+(config.value||0)+"' /><applet name='anesSigBlock' codebase='//inet/includes' code='SigBlock.class' archive='SigBlock.jar' width='301' height='76'></applet><anesSig><input type='button' value='Sign' onClick='saveThis()' /></anesSig>";

The java applet captures a signature, but I can’t figure out how to pass the sig data to the form control. I tried this:

$$('form_5').item('sig').value=anesSigBlock.sign();

but the data doesn’t show up when I call form.getValues(). I have also tried $$(‘form_5’).item(‘sig’).setValue(), but I get an undefined error. Any suggestions?

thanks.

HA HA!!! I got it. The code below lets me set my Custom Form Control:

var sigdata = anesSigBlock.sign();
$$('form_5').setValues({sig:sigdata});

“sig” is the id of my custom form control. Now when I call form.getValues() my control actually shows data. Hopefully this will help someone else too.

cheers.

However, I would still like to know how to access/use the setValue() and getValue of my custom components. Can someone show me a code snippet that demonstrates the correct usage? The tutorial only shows how to set it up.

thanks.

Actually you can use your first approach as well

$$('form_5').item('sig').value=anesSigBlock.sign();
$$('form_5').refresh('sig'); //repaint with new value

but form.setValue is a better approach, because it just changes the value of the element, without full repainting ( which means - it works faster )

to know how to access/use the setValue() and getValue of my custom components
setValue and getValue methods of form element used by form.getValues|setValues calls

setValue method of form elements requires html node as one of parameters, so it is not very usable for direct scripting. It possible to call it directly but it will not have any advantages against form.setValues , or do you have some specific reasons for direct calls?

Now that I understand how setValues() works (thanks for the explanation) I doubt I will be calling setValue() and getValue() directly. Really I was just curious because I might want to add other functions to custom controls, but I can’t even figure out how to access the standard ones. Can you post a line of code with a html node that shows how to do it?

thanks.

Something like next

dhx.ui.passive["textarea"].getValue(form._locateHTML("sig"));

textarea - type of input
form - owner form object

because it uses inner method ( _locateHTML ) it will work only with not compressed (_debug) version of code.