Are there any special things to keep in mind when making fields so they work inside of structure fields?
The link field doesn’t work in structure fields and only returns type is not defined
— which I can’t really understand. Outside of structure fields everything seems to be fine.
Blueprint outside of structure fields:
button:
label: Button
type: link
Blueprint inside of structure fields:
buttons:
label: Buttons
type: structure
fields:
button:
label: Button
type: link
@daybugging I still don’t know if this is a Kirby issue or missing documentation about custom fields in structure fields.
Could you narrow it down to which variable/object type is not defined
refers?
I guess it could be the type
stored in value
: https://github.com/medienbaecker/kirby-link-field/blob/master/index.js#L18
It works when the value is set, the issue only occurs with empty structure entries (newly created).
I tried setting $value
to an empty array with type
and link
set to null
, but it didn’t help.
Why does it work outside of structure fields though? 
Whew, I finally managed to fix it. One of those “why does it work?” moments, though.
I thought setting the $value
to an empty array with type
and link
in the index.php would have to work. It doesn’t. I have to check if a value is set in the index.js.
2 Likes
Don’t we all love nasty things like these?
Glad you found it!