Set up a computed field with an appropriate validator
Hi!
I am using CKAN 2.9 and I would like to have a field that is not set up by the user in the form, but computed separately and then displayed.
I started to set form_snippet to null, but by doing this, the field is always reset to null each time I try to modify the dataset.
I have been advised to use the keep_old_value_if_missing validator. When a value for a given field on the form is missing (which is my case), the previously existing value is given.
This is a problem for me because, at the beginning, there is no previously existing value. The validator as it is now cannot work for me, unless I manage to give a random default value at the beginning.
How can I modify this validator so that it does what I want?
what is the field computed from? You could add an output_validator to do the computation each time the dataset is accessed instead of saving it in the db.
It is getting its value from an API. I don't understand how output_validators work.
keep_old_value_if_missing seems like what you need then. Sounds like a small fix to make it work with initial missing values.
It is maybe a small fix but I am a bit confused as to how to do it.
This is more complicated than I imagined. I am going to leave this for a moment but it would be nice to have a validator for this use case in the future.