Closed medienbaecker closed 1 year ago
Because when the page is created, the value of the empty field is empty string " "
, while the value of a field is null
when creating an entry in the structure or object field.
I'm not sure that this idea could be break somethings but I've a solution. We can set empty string as fallback value like that
const value = values[key.toLowerCase()] ?? "";
Related line:
@afbora Does the issue only affect the structure field or do other fields behave the same inside a structure or object field?
@lukasbestle for structure, object field and for each field containing the form (not sure).
The source of the issue: the field values are empty string when the page is created. But the field values in the form (with in structure and object field) created by the fields are assigned as null
.
I'd say that this is the bug then. IMO the parent form and the "field form" of the structure and object fields should behave the same. It's also weird that the default
prop doesn't seem to have an effect in the "field form".
Yes, also doesn't work like you said when you define as default: ""
.
Related lines (for structure) that we do set default (null
when no default prop) while initialization of form:
I would agree that the solution we should aim is making sure that creating a new page and creating a new structure form produce the same results.
✅
Description
When using a select field inside of a structure or object, the field doesn't initially have a value — compared to using it directly in the page blueprint.
Why is this bad?
Let's say you're using a select field and other fields react to it via field conditions:
The text field is not shown initially. Only when changing the select field to some option and back to nothing it's shown. Interestingly enough it also works by saving the empty value and opening the structure/object again. I tried to set
default: ""
but it didn't work either.Expected behavior
I'd expect the select field to have an initial value of
""
just like it does outside of structure or object fields.To reproduce
Your setup
Kirby Version
3.8.1.1