Form Grid Layout
The formgrid setting in a schema controls how form fields are arranged in the admin dashboard. It uses CSS Grid to create multi-column layouts, allowing you to organize fields in rows and columns.
Basic Concept
Section titled “Basic Concept”Think of your form as a spreadsheet. Each row in your formgrid definition becomes a row in your form, and each word in that row represents a column. Fields are placed into named “cells” that you define.
row 1: [field1] [field2]row 2: [field3] [field3] <- field3 spans both columnsrow 3: [field4] [ . ] <- empty cell on the rightBasic Syntax
Section titled “Basic Syntax”In the schema form, the formgrid field is a textarea where:
- Each line represents a row in the grid
- Property names are separated by spaces
Simple Two-Column Layout
Section titled “Simple Two-Column Layout”title dateauthor categorycontent contentThis creates:
+------------------+------------------+| title | date |+------------------+------------------+| author | category |+------------------+------------------+| content |+------------------+------------------+Spanning Multiple Columns
Section titled “Spanning Multiple Columns”To make a field span multiple columns, repeat its name across those columns:
id idtitle titledate authorcontent contentThis creates:
+------------------+------------------+| id | <- spans both columns+------------------+------------------+| title | <- spans both columns+------------------+------------------+| date | author |+------------------+------------------+| content | <- spans both columns+------------------+------------------+Empty Cells
Section titled “Empty Cells”Use a period (.) to create an empty cell:
active .id idname categoryThis creates:
+------------------+------------------+| active | (empty) |+------------------+------------------+| id |+------------------+------------------+| name | category |+------------------+------------------+Section Dividers
Section titled “Section Dividers”Use --- on its own line to add a horizontal divider:
name email---address citystate zipThis creates:
+------------------+------------------+| name | email |+------------------+------------------+| ───────────────────────────────── | <- visual divider+------------------+------------------+| address | city |+------------------+------------------+| state | zip |+------------------+------------------+Section Headers
Section titled “Section Headers”Use ---Title Here--- to add a styled section heading:
id idname name---URL Setup---url urlslug slug---Dashboard Setup---category sortByThis creates:
+------------------+------------------+| id |+------------------+------------------+| name |+------------------+------------------+| URL Setup | <- styled heading+------------------+------------------+| url |+------------------+------------------+| slug |+------------------+------------------+| Dashboard Setup | <- styled heading+------------------+------------------+| category | sortBy |+------------------+------------------+Three or More Columns
Section titled “Three or More Columns”The grid automatically sizes based on the row with the most columns:
id id idfirst middle lastaddress address addresscity state zipcontent content contentThis creates a three-column layout:
+------------+------------+------------+| id |+------------+------------+------------+| first | middle | last |+------------+------------+------------+| address |+------------+------------+------------+| city | state | zip |+------------+------------+------------+| content |+------------+------------+------------+Important Rules
Section titled “Important Rules”Every Property Must Be Included
Section titled “Every Property Must Be Included”All properties defined in your schema must appear somewhere in the formgrid. Missing properties will cause the form layout to break.
If your schema has title, date, and content properties, this formgrid is incorrect:
title dateThe content property is missing and must be added.
Syntax Errors Break the Layout
Section titled “Syntax Errors Break the Layout”The formgrid parser is strict. Common issues include:
- Missing properties
- Typos in property names
- Inconsistent column counts without proper spanning
- Invalid characters in property names
Valid Property Name Characters
Section titled “Valid Property Name Characters”Property names in the grid must follow CSS identifier rules:
- Start with a letter, underscore, or hyphen
- Followed by letters, digits, hyphens, or underscores
- The special
.character is reserved for empty cells
Real-World Examples
Section titled “Real-World Examples”Blog Post Schema
Section titled “Blog Post Schema”id idtitle titledraft featureddate authorimage imagecategories categoriestags tagssummary summarycontent contentmedia mediagallery galleryextra extraupdated createdUser Authentication Schema
Section titled “User Authentication Schema”active activeid idimage imagename nameemail emailpassword passwordgroups loginCountexpiration createdmaxLoginCount lastloginEmail Template with Dividers
Section titled “Email Template with Dividers”active .id idname categorydescription description---to fromtoName fromNamereplyTo .cc bcc---subject subjectbodyHtml bodyHtmlbodyText bodyTextCollection Settings with Named Sections
Section titled “Collection Settings with Named Sections”id idname nameschema schema---URL Setup---url urlprettyUrl prettyUrl---Dashboard Setup---category labelPluralsortBy labelSingular---Public Access---publicOperations publicOperationsgroups groups- Start simple: Begin with a single-column layout, then add complexity
- Use sections: Break long forms into logical sections with headers or dividers
- Test your layout: After making changes, preview the form in the admin dashboard
- Match column counts: Ensure each row uses the same total number of cells (using spanning or
.for empty cells) - Keep related fields together: Group related fields on the same row or in the same section