Datatype text readonly

Dear all,

Now, i found that if i use datatype as text and put readonly (yes), It look
same as note. But i'm not sure, will it create a field in table of database?
Can i set the value to this field automatically? Because I have a value
that don't change and i want to store at the same as survey data.

Could you help me on this?

Bunhann,

If you want to set a value at survey-time and have it appear in the data as
a normal field, use a calculate field. Easy! (And if you want to show it in
a note, have a label that shows the calculated field...)

As we've discussed previously, I believe that only SurveyCTO currently
allows setting calculated default values for UI fields (i.e., for field
types other than "calculate").

Best,

Chris

··· On Wed, Aug 6, 2014 at 8:10 AM, Bunhann Thou wrote:

Dear all,

Now, i found that if i use datatype as text and put readonly (yes), It
look same as note. But i'm not sure, will it create a field in table of
database?
Can i set the value to this field automatically? Because I have a value
that don't change and i want to store at the same as survey data.

Could you help me on this?

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Does this mean having text field as read only and using calculate to calculate the field saves the data in the database as was being asked in the question @crobert ?

SurveyCTO has a range of options for dynamic defaults, calculations that happen only once a certain point in a survey is reached (and then not thereafter), and more -- but at this point I'm less sure of core ODK's capabilities along these lines. Certainly you can have a "calculate" field -- but if you want something dynamic in a "text" field, I'm not sure... So I'll let somebody more knowledgeable reply...

Chris

1 Like

Not really sure what your question is, @aonomike, but here's the behavior I'd expect from the current ODK tools.

  • A calculate field will save data in the database.
  • A read-only field with a default value will save that default value in the database.
  • A read-only field with no default value will not save data in the database
  • Calculates are not visible to the user. Read-only fields are.
  • Calculates can be dynamic, but defaults are static.
  • Calculates and read-only fields can be shown back to users in labels and hints using the ${} syntax.

Try this with a small form to confirm!

1 Like

Just to be clear (ie pedantic), any field can be shown back to users in labels and hints (including calculated fields, read-only fields with defaults, you-name-it...). :wink:

1 Like