type name label required default
text city City false City_name
I am collecting data from cities and would like to have the city name already in the default, and hidden to the viewer of the survey. However when I export the file, the city name is blank, despite being in default. Is there any way to hide a question and autofill it?
In your XLSForm you can use a âhiddenâ question type, and fill in your desired value in its default.
This will basically pre-populate a text value in the form submission data (ie instance XML) which will be submitted along with all the other user entered data, but it does not appear as an actual question in the displayed form itself, hence the user has no ability to change it.
Caveat: I donât think KoboToolbox KPI form builder exposes the âhiddenâ question type (although if you manually put it in your XLSForm itâll accommodate it). If you want to do this entirely using the Kobo form builder you can use a calculation control, and set its calculated value to your desired default, to achieve the same result.
What code can I use to put the âhiddenâ question type in and what column? Currently I am putting the desired answer in the default column. But it is showing in the survey, autofilled. Where can I hide the question?
Take a look at this XLSForm to see how to implement either a âhiddenâ control (unsupported by Kobo form builder) or an equivalent calculation control (supported):
FYI, it looks like Kobo form builder doesnât just not support âhiddenâ controls, but it will throw an error if you try to load and edit an XLSForm containing them, and will then remove them should you subsequently try to export the form. Iâve open a github issue to track: https://github.com/kobotoolbox/kpi/issues/2239
Which is to say, although both Enketo and Collect (and KoboCollect) clients will in fact support deployed XML forms generated from XLSForms that contain âhiddenâ controls, if you wish to edit any such XLSForms using the Kobo form builder theyâll get munted. So my recommendation for those using the Kobo form builder is to use the calculation approach.
Please, find the attached file ⌠ryon_1.xls (22 KB)
Please, find the attached new file ⌠[There are typos in file before] ryon_22.xls (22 KB)
I create âcalculateâ question type, then i give calculation [example : âJAKARTAâ],
Itâs hidden, but when you export the submissons you have the data.
I create a note to view a calculation, please delete it. Itâs just show you the calculation.
Correct. Using a calculation is the alternative (which I included also). The end result is the same, however the nature of XForms is that, depending on the client, calculations may need to be re-executed when anything changes (although in Collect there is an optimization to avoid this by calculating a dependency tree beteeen all calculations, and only re-executing those dependent upon each change). And re-evaluating XPath calculations that always return a constant/literal is just wasted CPU cycles.
Sticking a default value in the form instance XML is still the most efficient, which is what XLSForms âhiddenâ control does. But unfortunately itâs not supported in Kobo yet.
Hello,
Fortunately, XLSForms with âhiddenâ control can meanwhile be imported/deployed in KoBoToolbox and the form can be downloaded well. See Release Notes - version 2.020.52b. Hidden type is also available now in KoBo Form Builder.
A difference between âhiddenâ and calculation is: âhiddenâ will NOT appear in Report, but calculation type will.
But in table view and data download hidden type will appear, like calculation.
In form print-out (pdf) neither hidden nor calculation type will appear.
Side-notes:
A text type read-only will be treated in data download similar to a note type, i.e. doesnât show any (cell) values.
XLSOnline validator (2.0) gives a warning for hidden type without label (but not for calculation)
[row : 5] Question has no label: {ânameâ: âhiddenâ, âtypeâ: âhiddenâ, âdefaultâ: âthis default value is hiddenâ}. See ODK - XLSForm Online v2.x