Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

How can I set the page title to what I select in select field?

default discord avatar
razi_syedlast year
2

Hi,



I'm trying to make it so when I select and option in the select field, that field is used as the title for the page.



This is what my code looks like so far:



const Page: CollectionConfig = {
  slug: "page",
  admin: {
    useAsTitle: "title",
  },
  auth: false,
  fields: [
    {
      name: "pageType",
      label: "Page Type",
      type: "select",
      options: [
        {
          label: "Home",
          value: "home",
        },
        {
          label: "Location",
          value: "location",
        },
        {
          label: "Contact",
          value: "contact",
        },
      ],
    },


How do I make it so when, for example, I select "Home", that's what gets set for the title?

  • discord user avatar
    tylandavis
    last year

    Hey

    @206640514370371584

    , the

    useAsTitle

    property should be set to the

    name

    of the field you want to use. So in this case, you should set it to

    pageType

    .

  • default discord avatar
    razi_syedlast year

    Awesome, thank you! This is what worked for me

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.