Append a value to the dropdown

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Append a value to the dropdown

mbojja
Hi Alex - I'm using a rest api to populate a drop-down and would like to append an additional static value. Did not want pollute the original dataset. Can you please suggest a solution to append on the orbeon fr side?

Json returned by the rest service

{
  "success": true,
  "message": "Retrieved 251 countries.",
  "countryList": {
    "countries": [
      {
        "code": "AF",
        "name": "Afghanistan"
      },
      {
        "code": "AL",
        "name": "Albania"
      },
      {
        "code": "DZ",
        "name": "Algeria"
      }
    ]
  }
}

Need to append the below value 

 {
        "code": "OT",
        "name": "Other"
      }

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/0438d4c3-5d01-4a03-b5d8-f30a71ef0ceb%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Append a value to the dropdown

Joel Oates
Hi mbojja,

I've had a similar issue where I wanted a default or 'other' inside my
databound-select1, I Achieved it by adding an additional itemset inside the
databound-select1.

Here is my example:

<fr:databound-select1 xmlns="http://orbeon.org/oxf/xml/form-builder"
                            xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
                            id="control-2-control"
                            appearance="minimal"
                            resource="http://localhost:8080/somelistofstuff"
                            bind="control-2-bind">
    <xf:label ref="$form-resources/control-2/label"/>
    <xf:hint ref="$form-resources/control-2/hint"/>
    <xf:alert ref="$fr-resources/detail/labels/alert"/>
    <xf:itemset ref="list-summary">
        <xf:label ref="list-name"/>
        <xf:value ref="list-value"/>
    </xf:itemset>
    <xf:itemset ref="'othervalue'">
        <xf:label ref="'other'"/>
        <xf:value ref="'other'"/>
    </xf:itemset>
</fr:databound-select1>

I hope this helps!

Joel.

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1587174554606-0.post%40n4.nabble.com.