Show an selected option in the summary

Hi Support,
I try to show a selected value from a OptionField in the summary of an entity. However, the app gives a definitionerror: Parametrization summary item classification_status originates from param of type select, expects type from: text
Do you have any idea how to fix this?

Hi Bart,

Could you show the code of how you are trying the access the optionfield?

It should be something like this:

from viktor.parametrization import ViktorParametrization, OptionField

class Parametrization(ViktorParametrization):
    optionfield_sample = OptionField('This is an OptionField', options=['A', 'B'], default='A')

class Controller(ViktorController):
    ...
    def some_function(self, params, **kwargs):
        print(params.optionfield_sample)

Hi Jelle,

It is more something like this:

from viktor.parametrization import ViktorParametrization, OptionField

class Parametrization(ViktorParametrization):
    optionfield_sample = OptionField('This is an OptionField', options=['A', 'B'], default='A')

class Controller(ViktorController):
    ...
    summary = Summary(
    item_1=SummaryItem('Length', str, 'parametrization', ' optionfield_sample')
    )

Hi Bart,

Unfortunately, OptionFields are currently not supported in the Summary.
Fields that are supported are:

  • NumberField
  • IntegerField
  • TextField
    Ref to docs

Current workaround is to create a DataResult view and show the results there instead.
I hope this answers your question.
Regards,