Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(examples): migrates form-builder example to 3.0 #9681

Merged
merged 9 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
DATABASE_URI=mongodb://127.0.0.1/payload-template-blank-3-0
DATABASE_URI=mongodb://127.0.0.1/payload-form-builder-example
PAYLOAD_SECRET=YOUR_SECRET_HERE
PAYLOAD_SEED=true
NEXT_PUBLIC_PAYLOAD_URL=http://localhost:3000
8 changes: 8 additions & 0 deletions examples/form-builder/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
extends: 'next',
root: true,
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
}
53 changes: 53 additions & 0 deletions examples/form-builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Payload Form Builder Example

The [Payload Form Builder Example](https://github.com/payloadcms/payload/tree/main/examples/form-builder/payload) demonstrates how to implement the official [Form Builder Plugin](https://payloadcms.com/docs/plugins/form-builder) in [Payload](https://github.com/payloadcms/payload).

**IMPORTANT—This example includes a fully integrated Next.js App Router front-end that runs on the same server as Payload.**

## Quick Start

1. Clone this repo
2. `cd` into this directory and run `pnpm i --ignore-workspace`\*, `yarn`, or `npm install`

> \*If you are running using pnpm within the Payload Monorepo, the `--ignore-workspace` flag is needed so that pnpm generates a lockfile in this example's directory despite the fact that one exists in root.

3. `cp .env.example .env` to copy the example environment variables

4. `pnpm dev`, `yarn dev` or `npm run dev` to start the server
- Press `y` when prompted to seed the database
5. `open http://localhost:3000` to access the home page
6. `open http://localhost:3000/admin` to access the admin panel
- Login with email `demo@payloadcms.com` and password `demo`

That's it! Changes made in `./src` will be

## How it works

The [Form Builder Plugin](https://payloadcms.com/docs/plugins/form-builder) automatically adds the `forms` and `formSubmissions` collections to your config which your front-end can use to query forms and submit form data. You can embed forms into layout building blocks by referring a `forms` document in a relationship field.

See the official [Form Builder Plugin](https://payloadcms.com/docs/plugins/form-builder) for full details.

## Development

To spin up this example locally, follow the [Quick Start](#quick-start).

### Seed

On boot, a seed script is included to scaffold a basic database for you to use as an example. You can remove `pnpm seed` from the `dev` script in the `package.json` to prevent this behavior. You can also freshly seed your project at any time by running `pnpm seed`. This seed creates a user with email `demo@payloadcms.com` and password `demo` along with a home page and an example page with two versions, one published and the other draft.

> NOTICE: seeding the database is destructive because it drops your current database to populate a fresh one from the seed template. Only run this command if you are starting a new project or can afford to lose your current data.

## Production

To run Payload in production, you need to build and serve the Admin panel. To do so, follow these steps:

1. Invoke the `next build` script by running `pnpm build` or `npm run build` in your project root. This creates a `.next` directory with a production-ready admin bundle.
1. Finally run `pnpm start` or `npm run start` to run Node in production and serve Payload from the `.build` directory.

### Deployment

The easiest way to deploy your project is to use [Payload Cloud](https://payloadcms.com/new/import), a one-click hosting solution to deploy production-ready instances of your Payload apps directly from your GitHub repo. You can also choose to self-host your app, check out the [Deployment](https://payloadcms.com/docs/production/deployment) docs for more details.

## Questions

If you have any issues or questions, reach out to us on [Discord](https://discord.com/invite/payload) or start a [GitHub discussion](https://github.com/payloadcms/payload/discussions).
10 changes: 0 additions & 10 deletions examples/form-builder/next-app/.editorconfig

This file was deleted.

1 change: 0 additions & 1 deletion examples/form-builder/next-app/.env.example

This file was deleted.

21 changes: 0 additions & 21 deletions examples/form-builder/next-app/.eslintrc.cjs

This file was deleted.

38 changes: 0 additions & 38 deletions examples/form-builder/next-app/.gitignore

This file was deleted.

38 changes: 0 additions & 38 deletions examples/form-builder/next-app/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions examples/form-builder/next-app/app/[slug]/page.tsx

This file was deleted.

53 changes: 0 additions & 53 deletions examples/form-builder/next-app/app/layout.tsx

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading