Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for fetching data for a select_one/multiple from a database #97

Open
dagoss opened this issue Feb 7, 2018 · 3 comments
Open

Comments

@dagoss
Copy link

dagoss commented Feb 7, 2018

We have a use-case where opens for select_one/multiple need to come from a database when the form is rendered. We want to either put either (1) URL for the data or (2) an SQL statement to get the data

This doesn't seem to be something supported by XLSForms. We were considering just adding a query or data_url column to the choices worksheet in our implementation, but it feels terrible.

@MartijnR
Copy link
Contributor

MartijnR commented Feb 7, 2018

A recent not-yet-documented addition is the type xml-external. See more XLSForm/pyxform#107.

This is already used by some XLSForm users to do exactly what you describe. The database lives on a webserver and the jr://file/etc.xml is resolved in the media manifest that ODK-compliant servers support. You can use that XML data for anything in the XLSForm.

Serving custom content could be done across tools based on the authenticated user. In Enketo there is also a way to pass a query parameter in the webform URL that can be copied into requests for /formList (and thereby show custom manifest URLs based on the parameter). This provides a finer-grained control to customize the content of the XML data file.

@MartijnR
Copy link
Contributor

#99

@rhunwicks
Copy link

@dagoss we are using select_one_from_file in this situation. For example, the XLSForm question has select_one_from_file my_list.csv, and then when we deploy the form we set up the media for the form with https://myapp.example.com/api/my_list?format=csv. This allows to deploy the same form in different places and set the url for the REST API that serves the data at deployment so we can change it for staging, production, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants