[daisy] Re: Example .js snippet for accessing fields
Robert Cecil
rob.cecil at gmail.com
Fri Dec 1 13:15:08 CST 2006
I think I found it.
Here's my flow.js snippet:
var schema = repository.getRepositorySchema();
var selectionList = schema.getFieldTypeByName("StudyType",
false).getSelectionList();
var typeArray = new Array();
var selectionListItems = selectionList.getItems();
for (var i = 0; i < selectionListItems.length; i++) {
var listItem = selectionListItems[i];
var listLabel = listItem.getLabel(java.util.Locale.getDefault());
typeArray[i] = { value:listItem.getValue(), label:listLabel };
}
// show form
var viewData = new Object();
viewData["CocoonFormsInstance"] = form.form;
viewData["pageContext"] = daisy.getPageContext();
viewData["submitPath"] = mountPoint + "/" + siteConf.getName
() + "/ext/forms/conceptproposal";
viewData["locale"] = locale;
viewData["navigationTree"] = navigationData;
viewData["formTemplate"] = daisy.resolve
("conceptproposal_form_template.xml");
viewData["studytypelist"] = typeArray;
cocoon.sendPage(daisy.getDaisyCocoonPath() + "/
GenericFormPipe", viewData);
Here's how my form consumes it:
<fd:field id="proposal-studytype" required="true">
<fd:label>Type of study:</fd:label>
<fd:datatype base="string"/>
<fd:selection-list type="flow-jxpath" list-path="studytypelist"
value-path="value" label-path="label">
</fd:selection-list>
</fd:field>
On Dec 1, 2006, at 1:32 PM, Robert Cecil wrote:
> Hi,
>
> I need to access a selection list defined in a field in the
> repository in an extension form, via flow_jxpath, e.g.
>
> <fd:selection-list type="flow-jxpath" list-path="myList"
> value-path="value" label-path="label" />
>
> My question is how do I query the repository (via the javascript
> api) to find the list of name/value pairs that I created when I
> defined a field? More specifically, if I created a field in the
> backend, with a static selection list (manual enumeration) of
> values and labels, how would I retrieve that via javascript to
> populate a CForms front-end form?
>
> Thanks in advance!
>
> Rob Cecil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cocoondev.org/pipermail/daisy/attachments/20061201/c4a0b1e9/attachment.htm
More information about the daisy
mailing list