Using the slug input field inside Layout field

Inside my Layout field I have a field block used as a Section Header. Inside this Section header there is the field sectionTitle.

The editor should later be able to create hash-links to those Sections, therefore I add the corresponding ID with sectionTitle->slug() to the Section.

As described here we can place a synced slug field, which would be great for the Editor to see what the actual Section ID will be.

I wonder if this is even possible inside a block which lives in a layoutsection?
Of course there will be multiple sections with multiple sectionTitles on the Page.
Can I somehow query the corresponding sectionTitle field in this case?

The slug field works within a block, no matter if this block is inside a layout field or inside a blocks field.

Yes, but only for Manual Input, right?
I can not sync it with a field inside the same block?

Yes, you can. This works:

name: H2
icon: title
wysiwyg: true
preview: heading
fields:
  text:
    label: Heading text
    type: writer
    inline: true
  slug:
    label: Id
    type: slug
    sync: text

Hm, yes you are right this works.
But it does not work in my fields block.

This is the block Blueprint (there are some more fields and tabs):

name: Section Header
icon: title
preview: fields
wysiwyg: true

tabs:
  main:
    label: Main
    fields:
      sectionTitle:
        width: 1/2
        label: Section Title
        type: text
        placeholder: Section Title
      sectionID:
        width: 1/2
        label: Section ID
        type: slug
        sync: sectionTitle

Could there be a problem with the new fields block?
Or did I something wrong?

Use

sync: sectiontitle

and it will work.

1 Like

Oh wow, sometimes it is that simple!
Thank you for this input!