TS552, Solaris
Hi,
We are trying to use FormAPI to getValue on a readonly field. ie this is what is in our DCT:
<item name="metadata">
<item name="id">
<label>Id Primary Content</label>
<description>Id Primary Content</description>
<readonly></readonly>
</item>
</item>And using this code in the DCT:
<script>
<![CDATA[
function init() {
var item;
item = IWDatacapture.getItem("/metadata/id");
//item.setReadOnly(1);
alert("Value is: "+item+" getValue is "+item.getValue());
}
//Now do the initialization...
init();
]]>
</script>However this returns a 'null' value in
item.getValue().
But if we change our DCT to look like this:
<item name="metadata">
<item name="id">
<label>Id Primary Content</label>
<description>Id Primary Content</description>
<text></text>
</item>
</item>And change our Javascript code to force that field to be readonly (uncommenting the following line from above:
item.setReadOnly(1);Then it returns the correct value for that field. The field also shows up correctly as readonly.
I know this is a little bit of a way around it, but I couldn't get the value unless the field was initially a text field. Is this correct, or is there a better way of doing it?
Would there be any issues of this field ever being able to be edited by a user if the Javascript does not run?
Any advice here would be valuable.
Thanks,
Jeremy
Update! Just read the following in the FormAPI docs:
"The FormAPI does not support <readonly> items. It is anticipated that their use will be deprecated in future releases. "
So thats why it wasn't working.
Edited by Jeremy on 04/23/03 00:10 AM (server time).