You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+86-46Lines changed: 86 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,31 +15,31 @@ This package aims to help you add dynamic, configurable fields to your Filament
15
15
16
16
## Features
17
17
18
-
- 🎯 **Easy Integration**: Seamlessly integrates with your Filament resources
19
-
- 🔧 **Configurable Fields**: Add and manage custom fields for your models
20
-
- 🎨 **Built-in Field Types**: Includes common Filament form fields like:
21
-
- Text
22
-
- Textarea
23
-
-Rich Text Editor
24
-
- Select
25
-
- Checkbox
26
-
- Checkbox List
27
-
- Key-Value
28
-
- Radio
29
-
- Toggle
30
-
- Color Picker
31
-
- DateTime
32
-
- Tags
33
-
- ✨ **Extensible**: Create your own custom field types
34
-
- 🔄 **Data Mutation**: Hooks to modify field data before filling forms or saving
35
-
- 🏢 **Multi-tenant Support**: Built-in support for multi-tenant applications
18
+
-🎯 **Easy Integration**: Seamlessly integrates with your Filament resources
19
+
-🔧 **Configurable Fields**: Add and manage custom fields for your models
20
+
-🎨 **Built-in Field Types**: Includes common Filament form fields like:
21
+
- Text
22
+
- Textarea
23
+
-Rich Text Editor (with Jump Anchor plugin)
24
+
- Select
25
+
- Checkbox
26
+
- Checkbox List
27
+
- Key-Value
28
+
- Radio
29
+
- Toggle
30
+
- Color Picker
31
+
- DateTime
32
+
- Tags
33
+
-✨ **Extensible**: Create your own custom field types
34
+
-🔄 **Data Mutation**: Hooks to modify field data before filling forms or saving
35
+
-🏢 **Multi-tenant Support**: Built-in support for multi-tenant applications
36
36
37
37
This package is perfect for scenarios where you need to:
38
-
- Add dynamic custom fields to your models
39
-
- Allow users to configure form fields through the admin panel
40
-
- Build flexible content management systems
41
-
- Create customizable settings pages
42
38
39
+
- Add dynamic custom fields to your models
40
+
- Allow users to configure form fields through the admin panel
41
+
- Build flexible content management systems
42
+
- Create customizable settings pages
43
43
44
44
## Installation
45
45
@@ -63,7 +63,7 @@ The content of the `fields.php` file is as follows:
63
63
<?php
64
64
65
65
return [
66
-
66
+
67
67
'tenancy' => [
68
68
'is_tenant_aware' => true,
69
69
@@ -137,6 +137,41 @@ class ContentResource extends Resource
137
137
}
138
138
```
139
139
140
+
### Field Configuration
141
+
142
+
#### Validation Rules
143
+
144
+
Each field supports validation rules that can be configured through the admin interface. The package includes support for all standard Laravel and Filament validation rules:
-**Pattern Rules**: Regex, starts/ends with, in/not in list
153
+
-**Database Rules**: Exists, unique
154
+
155
+
##### Field Dependencies
156
+
157
+
Validation rules can depend on other fields in the form:
158
+
159
+
-**Field Comparison**: Compare values with other fields (`same`, `different`, `greater_than`, etc.)
160
+
-**Conditional Requirements**: Make fields required based on other field values (`required_if`, `required_unless`)
161
+
-**Multi-field Dependencies**: Require fields based on multiple other fields (`required_with_all`, `required_without_all`)
162
+
163
+
When no other fields are available for dependency rules, the field selection will be disabled and show a helpful message.
164
+
165
+
#### Visibility Rules
166
+
167
+
Control when fields are shown or hidden based on conditions:
168
+
169
+
-**Conditional Display**: Show/hide fields based on other field values
170
+
-**Dynamic Forms**: Create adaptive forms that change based on user input
171
+
-**Complex Logic**: Support for multiple conditions and logical operators
172
+
173
+
The visibility system works seamlessly with validation rules to create intelligent, user-friendly forms.
174
+
140
175
### Making a resource page configurable
141
176
142
177
To make a resource page configurable, you need to add the `CanMapDynamicFields` trait to your page. For this example, we'll make a `EditContent` page configurable.
@@ -146,11 +181,7 @@ To make a resource page configurable, you need to add the `CanMapDynamicFields`
@@ -299,21 +330,22 @@ class RepeaterField extends Base
299
330
```
300
331
301
332
Available base fields that can be excluded:
302
-
-`required` - Required field toggle
303
-
-`disabled` - Disabled field toggle
304
-
-`hidden` - Hidden field toggle
305
-
-`helperText` - Helper text input
306
-
-`hint` - Hint text input
307
-
-`hintColor` - Hint color picker
308
-
-`hintIcon` - Hint icon input
309
-
-`defaultValue` - Default value input
333
+
334
+
-`required` - Required field toggle
335
+
-`disabled` - Disabled field toggle
336
+
-`hidden` - Hidden field toggle
337
+
-`helperText` - Helper text input
338
+
-`hint` - Hint text input
339
+
-`hintColor` - Hint color picker
340
+
-`hintIcon` - Hint icon input
341
+
-`defaultValue` - Default value input
310
342
311
343
#### Best practices for field exclusion
312
344
313
-
-**Only exclude what doesn't apply**: Don't exclude fields just because you don't use them - only exclude fields that conceptually don't make sense for your field type
314
-
-**Document your exclusions**: Add comments explaining why certain fields are excluded
315
-
-**Test thoroughly**: Make sure your field still works correctly after excluding base fields
316
-
-**Consider inheritance**: If your field extends another custom field, make sure to call `parent::excludeFromBaseSchema()` if you need to add more exclusions
345
+
-**Only exclude what doesn't apply**: Don't exclude fields just because you don't use them - only exclude fields that conceptually don't make sense for your field type
346
+
-**Document your exclusions**: Add comments explaining why certain fields are excluded
347
+
-**Test thoroughly**: Make sure your field still works correctly after excluding base fields
348
+
-**Consider inheritance**: If your field extends another custom field, make sure to call `parent::excludeFromBaseSchema()` if you need to add more exclusions
317
349
318
350
Example of a field that excludes multiple base fields:
319
351
@@ -342,6 +374,14 @@ To register your own fields, you can add them to the `fields.fields` config arra
342
374
],
343
375
```
344
376
377
+
## Documentation
378
+
379
+
### Rich Editor Plugins
380
+
381
+
The package includes a powerful Rich Editor with custom plugins:
382
+
383
+
-**[Jump Anchor Plugin](docs/jump-anchor-plugin.md)** - Add anchor links to selected text for navigation and jumping to specific sections
384
+
345
385
## Testing
346
386
347
387
```bash
@@ -362,8 +402,8 @@ Please review [our security policy](../../security/policy) on how to report secu
0 commit comments