Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Form API replicant oddness
OliStreek
Hi everyone,
My customer's just upgraded from 5.5.2 to 6.5 sp2. I'd written a DCT a couple of weeks ago that worked fine on 5.5.2, but it doesn't work now. I've stripped it down to something really simple and there seems to be a problem addressing replicants - but I can't see what I'm doing wrong.
The DCT below has a field_1 and field_2; field_2 is in a replicant. I've got three lines of code that reference each item, and all the code should do is display the item type when the form is saved, then abort the save. For field_1 and the replicant itself, I see what I expect to, for field_2, the javascript just doesn't seem to run, and I get a server error - "Save was unsuccessful. Invalid category/type null was received."
From reading the 6.5 form API guide, I reckon my method of addressing the item in the replicant should still work. Can anyone see what I'm doing wrong here?
Thanks,
Oli
<?xml version="1.0" standalone="no"?>
<!DOCTYPE datacapture SYSTEM "datacapture5.0.dtd">
<data-capture-requirements type="content" name="x">
<ruleset name="x">
<description>test</description>
<item name="field_1">
<text size="6" maxlength="6" required="t" />
</item>
<item name="article-link">
<label>Link</label>
<replicant min="1" max="1" default="1">
<item name="field_2">
<label>Link URL</label>
<text size="64" maxlength="256" required="t" />
</item>
</replicant>
</item>
<script><![CDATA[
init();
function init() {
IWEventRegistry.addFormHandler("onSaveValid", setUrl);
}
function setUrl() {
// This works...
//var theItem = IWDatacapture.getItem("/field_1");
// This works...
//var theItem = IWDatacapture.getItem("/article-link");
// This doesn't...
var theItem = IWDatacapture.getItem("/article-link[1]/field_2");
alert(theItem.getType());
return false;
}
]]></script>
</ruleset>
</data-capture-requirements>
Find more posts tagged with
Comments
jbonifaci
You can argue whether it is right or wrong that it should work this way... but the problem is, you have a min and a max of one. Because of this, you can't refer to it by instance number, as there is always only one instance. So you need to do this:
var theItem = IWDatacapture.getItem("/article-link/field_2");
If you change your min to 0 or your max to 2 or higher, you would then need to append the instance number as you were doing.
~Jeff
OliStreek
Jeff,
It never occurred to me that form API would be that clever. Thanks!
Oli