Extend field inside a structure field?

I have a field blueprint for languages that I’d like to reuse in other blueprints:

blueprints/fields/language.yml

type: tags
accept: options
options:
  - AA
  - AB
  - AE
  - AF
  - AK
  - AM
  - ...

I’m trying to extend this in a structure field like so:

videos:
    label: Videos
    type: structure
    fields:
      language:
        extends: fields/language
        width: 1/4
      ...

The field seems to work and populates/autocompletes correctly, but when I try to save, I get the error:

can’t access property “label”, e is null

Am I doing something wrong? Or is this not supported?

Have you tried to add a field label?

Either inside the structure field or in the language.yml?

label: Tags
type: tags
accept: options
options:
  - AA
  - AB
  - AE
  - AF
  - AK
  - AM
  - ...

(Just guessing, not tested)

I’ve tried all permutations sadly to no avail:

  • No labels
  • Label in structure, no label in language.yml
  • Label in language.yml, no label in structure
  • Label in both

Interestingly, it works without the extends key, like this:

videos:
    label: Videos
    type: structure
    fields:
      language: fields/language

But that is not helpful.

It seems that when I rename the field, it starts to work?

    fields:
      videos:
        label: Videos
        type: structure
        fields:
          somefield:
            extends: fields/language
            width: 1/4
1 Like

For some reason that wasn’t working for me either, but I debugged it by pulling everything nested out of their templates and putting them directly into the blueprint and noticed I was running into the same problem.

I realized that changing the name of the field from languages fixed it, is there a conflict with that name for some reason?

  videos:
    label: Videos
    type: structure
    fields:
      lang:
        label: Language
        extends: fields/language

Oh, you beat me to it :slight_smile: I suppose the question still stands, if somehow that causes a conflict with language, even though my site is not multilingual.

Looks like some conflict, yes. Because you will have the same issue even without extending the field.

In general, I can only recommend not to use Kirby’s method names for your fields, it will only lead to problems sooner or later.

1 Like

Ah yes, I didn’t realize that my field had been initially named lang, and I renamed it to language upon putting it into an extendable field.

Thanks as always @texnixe