Skip to content

Commit 228dab6

Browse files
committed
docs: fix field type data mappings and add naming conventions
- Fix datetime key typo (datetime → date-time) in SKILL.md - Correct data storage columns to match actual FieldSchema mappings - Add project-prefix naming recommendations for custom field types - Update star-rating example to use acme-star-rating prefix
1 parent 072d9a8 commit 228dab6

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

docs/content/2.essentials/3.field-types.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Custom Fields includes 20+ pre-configured field types:
1313

1414
| Field Type | Key | Data Type | Description |
1515
|------------|-----|-----------|-------------|
16-
| **Text Input** | `text` | String | Basic text input with validation |
17-
| **Email** | `email` | String | Email input with validation |
18-
| **Phone** | `phone` | String | Phone number input |
19-
| **Link** | `link` | String | URL validation and formatting |
16+
| **Text Input** | `text` | Text | Basic text input with validation |
17+
| **Email** | `email` | Multi-choice | Email input with validation |
18+
| **Phone** | `phone` | Multi-choice | Phone number input |
19+
| **Link** | `link` | Multi-choice | URL validation and formatting |
2020
| **Textarea** | `textarea` | Text | Multi-line text input |
2121
| **Rich Editor** | `rich-editor` | Text | WYSIWYG editor with formatting |
2222
| **Markdown Editor** | `markdown-editor` | Text | Markdown syntax with preview |
@@ -32,7 +32,7 @@ Custom Fields includes 20+ pre-configured field types:
3232
| **Toggle Buttons** | `toggle-buttons` | Single-choice | Button group selection |
3333
| **Date** | `date` | Date | Date picker |
3434
| **Date Time** | `date-time` | DateTime | Date and time picker |
35-
| **Color Picker** | `color-picker` | String | Visual color selection |
35+
| **Color Picker** | `color-picker` | Text | Visual color selection |
3636
| **File Upload** | `file-upload` | String | File upload with validation |
3737
| **Record** | `record` | Multi-choice | Polymorphic model lookup |
3838

@@ -78,7 +78,7 @@ class StarRatingFieldType extends BaseFieldType
7878
public function configure(): FieldSchema
7979
{
8080
return FieldSchema::numeric()
81-
->key('star-rating')
81+
->key('acme-star-rating')
8282
->label('Star Rating')
8383
->icon('heroicon-o-star')
8484
->formComponent(function (CustomField $customField) {
@@ -292,7 +292,10 @@ enum FieldDataType: string
292292
## Best Practices
293293

294294
1. **Use Existing Filament Components**: Build on Filament's components like `Select`, `TextInput`, etc.
295-
2. **Follow Naming Conventions**: Use kebab-case for keys (e.g., `star-rating`, `country-select`)
295+
2. **Follow Naming Conventions**:
296+
- Use `kebab-case` for keys (e.g., `star-rating`, `country-select`)
297+
- **Use a project prefix** for custom types (e.g., `acme-star-rating`) to avoid conflicts with built-in types
298+
- Only skip the prefix when intentionally replacing a built-in type
296299
3. **Choose the Right Data Type**: Select the data type that matches how your field's values should be stored
297300
4. **Use Closures for Flexibility**: For complex components, use closure-based definitions
298301
5. **Test Your Components**: Ensure your field type works in forms, tables, and infolists

resources/boost/skills/custom-fields-development/SKILL.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,17 @@ public function getColumns(): array
138138

139139
| Type | Key | Data Storage |
140140
|------|-----|--------------|
141-
| Text | `text` | string_value |
142-
| Email | `email` | string_value |
141+
| Text | `text` | text_value |
142+
| Email | `email` | json_value |
143143
| Phone | `phone` | json_value |
144144
| Textarea | `textarea` | text_value |
145145
| Rich Editor | `rich-editor` | text_value |
146146
| Markdown | `markdown-editor` | text_value |
147-
| Link | `link` | string_value |
147+
| Link | `link` | json_value |
148148
| Number | `number` | integer_value |
149149
| Currency | `currency` | float_value |
150150
| Date | `date` | date_value |
151-
| DateTime | `datetime` | datetime_value |
151+
| DateTime | `date-time` | datetime_value |
152152
| Select | `select` | string_value |
153153
| Multi-Select | `multi-select` | json_value |
154154
| Checkbox | `checkbox` | boolean_value |
@@ -157,9 +157,27 @@ public function getColumns(): array
157157
| Toggle | `toggle` | boolean_value |
158158
| Toggle Buttons | `toggle-buttons` | string_value |
159159
| Tags Input | `tags-input` | json_value |
160-
| Color Picker | `color-picker` | string_value |
161-
| File Upload | `file-upload` | json_value |
162-
| Record Select | `record` | string_value / json_value |
160+
| Color Picker | `color-picker` | text_value |
161+
| File Upload | `file-upload` | string_value |
162+
| Record Select | `record` | json_value |
163+
164+
### Field Type Key Naming
165+
166+
**Convention:** Use `kebab-case` for all field type keys.
167+
168+
**For custom field types**, use a project prefix to avoid conflicts:
169+
170+
| Scenario | Pattern | Example |
171+
|----------|---------|---------|
172+
| New custom type | `{project}-{name}` | `acme-star-rating` |
173+
| Extended built-in | `{project}-{original}` | `acme-rich-editor` |
174+
| Replace built-in | Same key | `rich-editor` |
175+
176+
**Why prefix?**
177+
- Avoids accidental override of built-in types
178+
- Future-proof against new package versions
179+
- Clear identification in database/UI
180+
- Safe for multi-vendor environments
163181

164182
## Feature Flags
165183

0 commit comments

Comments
 (0)