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 add a second save button to the bottom of a collection page.In my collection I'm perform

default discord avatar
blazehazes2 years ago
4

My collection is performing an API request so I want to add a button that will make the initiate the request and save the page



I’ve got an admin component setup but I’m unsure on how to make the page save



I began following the examples here -

https://payloadcms.com/docs/admin/components#collections

but run into errors:



'DefaultButton' refers to a value, but is being used as a type here. Did you mean 'typeof DefaultButton'?ts(2749)


Type 'boolean' is not assignable to type '() => void'.ts(2322)


The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.ts(2362)


I'm guessing DefaultButton needs importing but I dont know where to import it from

  • default discord avatar
    nvskx2 years ago

    i import it from "payload/dist/admin/components/elements/Button"



    but thats button, so somewhere in elements there should be an element called DefaultButton

  • default discord avatar
    blazehazes2 years ago

    I removed that line and returned some text, didn't realise but It's not what I need.



    I need a new button at the bottom of an edit view that will save the page.



    I'm now using this example but again get errors everywhere when i use the supplied code



    https://github.com/payloadcms/payload/blob/main/test/admin/components/views/CustomView/index.tsx

    Its being imported at the top like



    import React, { Fragment, useEffect } from 'react'
  • default discord avatar
    nvskx2 years ago

    are you by some chance writing jsx components in a ts file?

  • default discord avatar
    blazehazes2 years ago

    HAH thats the one, thats got me a couple times!



    Thank you!

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.