How would check for null values in the panel

Check for “null”

From time to time I have the problem where I want to know if the value is set or skipped.

It works well for a text field. When it’s empty, I know it’s not set. I use an empty string as null in that case.

Other field types are more problematic.

Checkboxes

When I use a checkboxes field, I don’t know if no checkboxes are filled or if the panel user skipped to fill it in. How would you solve it? Add an additional checkbox that say active?

Checkbox, radiobuttons, toggle and select

The same problem goes for checkbox, radiobuttons, toggle and select.

Any ideas are welcome.

Isn’t it the same logic as with text fields? If there is no value, they aren’t checked/toggled/selected.

Doesn’t it come back to the question if something is “required” or not? If you expect input, you should make it required. If not, then the editor could purposely let it blank/unselected/unchecked (Or has “skipped” the fields, agreed, but they can also enter jibberish into text fields “just to have some value in it”. So imho it’s up to the editors to manage the content properly).

I’ll explain some more.

Checkboxes

This is from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox:

Let’s say this is the panel (I don’t have Kirby 2 installed on this computer):

image

Template/snippets

Case 1: In my template/snippet I want to say Unknown if the panel user skipped to fill the checkboxes because the user did not know the answer to the question.
Case 2: In my template/snippet I want to say No monsters if the panel user activly did not check any fields.

Seems to me it’s hard to figure out if an editor

  • leaves a field blank because he didn’t know the answer
  • leaves a field blank because none of the options matched

Maybe something like a conditional (pre-)field would help here? A checkbox-field which states “feature some features”, and if checked it reveals another field with “monster features” as shown in your screenshot.
E.g. as suggested once here or with the fieldtoggle field.

Or maybe add a last option which states “none of the above”?

1 Like

A combination of a checkbox and a togglefield would be helpful. When not used the checkboxes are not visible. At the same time the checkbox knows if the field is active or not in the snippet.

I don’t want to build such a field right now. In the meantime I will probably include an additional checkbox within the checkboxes field that I set to undefined by default.

In the past, I’ve simply added help text at the bottom of the field, that tells the user that “if no options are selected, you will have no monsters”.