Import instead of code: panel forms (steps, choice lists, dates), layout, page route, GEO routes, links, section fields
- Forms: step and checkboxGroup field types (radio, date on), server validation for them, useBuilderForm (logic) + BuilderForm (unstyled default) + RenderForm (/rsc: rich text, bound action, public part of the form only — the Emails tab never reaches the browser) - Notifications: next / back / stepOf texts - createContentHelpers: getSiteShell, getFormTexts, getLinkOptions, resolveLink, resolveNav, resolvePageRedirect, one-line route handlers (llms, llms-full, md, mcp, health, indexnow, manifest) - /rsc: SiteProviders, createPageRoute, createNotFoundPage - resolveLink / resolveNav / homeSlugFrom, buildSectionHeaderField / buildSectionSettingsField - Dev sandbox frontend built on these imports; tests (unit + real Payload) Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import type { Block, Field } from 'payload'
|
||||
|
||||
/**
|
||||
* Extra form-builder field types — what the built-in set can't express:
|
||||
*
|
||||
* - `step` — a divider: fields below it (until the next Step) are one
|
||||
* screen of a step-by-step form, with Next / Back buttons.
|
||||
* Carries no value.
|
||||
* - `checkboxGroup` — a list of options where the visitor ticks several
|
||||
* ("Services you're interested in"). Value: string[].
|
||||
*
|
||||
* Plain English labels (the panel is EN). Rendered by BuilderForm /
|
||||
* useBuilderForm, validated by submitForm like every other field.
|
||||
*/
|
||||
|
||||
const name: Field = {
|
||||
name: 'name',
|
||||
type: 'text',
|
||||
admin: { description: 'Technical name, e.g. "services" — no spaces.', width: '50%' },
|
||||
label: 'Name (lowercase, no special characters)',
|
||||
required: true,
|
||||
}
|
||||
const label: Field = { name: 'label', type: 'text', admin: { width: '50%' }, label: 'Label', localized: true }
|
||||
const width: Field = { name: 'width', type: 'number', admin: { width: '50%' }, label: 'Field width (percentage)' }
|
||||
const required: Field = { name: 'required', type: 'checkbox', admin: { width: '50%' }, label: 'Required' }
|
||||
|
||||
export const stepBlock: Block = {
|
||||
slug: 'step',
|
||||
fields: [
|
||||
{
|
||||
name: 'title',
|
||||
type: 'text',
|
||||
admin: {
|
||||
description:
|
||||
'Starts a new step: the fields below it (until the next Step) are shown together, with Next / Back buttons. Leave the form without Steps for a single-screen form.',
|
||||
},
|
||||
label: 'Step title',
|
||||
localized: true,
|
||||
},
|
||||
{ name: 'description', type: 'textarea', admin: { rows: 2 }, label: 'Step description', localized: true },
|
||||
],
|
||||
labels: { plural: 'Steps', singular: 'Step' },
|
||||
}
|
||||
|
||||
export const checkboxGroupBlock: Block = {
|
||||
slug: 'checkboxGroup',
|
||||
fields: [
|
||||
{ type: 'row', fields: [name, label] },
|
||||
{ type: 'row', fields: [width, required] },
|
||||
{
|
||||
name: 'options',
|
||||
type: 'array',
|
||||
fields: [
|
||||
{
|
||||
type: 'row',
|
||||
fields: [
|
||||
{ name: 'label', type: 'text', admin: { width: '50%' }, label: 'Label', localized: true, required: true },
|
||||
{ name: 'value', type: 'text', admin: { width: '50%' }, label: 'Value', required: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
labels: { plural: 'Options', singular: 'Option' },
|
||||
minRows: 1,
|
||||
},
|
||||
{
|
||||
type: 'row',
|
||||
fields: [
|
||||
{ name: 'minSelected', type: 'number', admin: { description: 'Empty = no minimum (Required = at least one).', width: '50%' }, label: 'Minimum selected', min: 0 },
|
||||
{ name: 'maxSelected', type: 'number', admin: { description: 'Empty = no limit.', width: '50%' }, label: 'Maximum selected', min: 1 },
|
||||
],
|
||||
},
|
||||
],
|
||||
labels: { plural: 'Checkbox groups', singular: 'Checkbox group' },
|
||||
}
|
||||
Reference in New Issue
Block a user