@@ -83,6 +83,12 @@ return [
8383 'selectable_resources' => [
8484 // App\Filament\Resources\ContentResource::class,
8585 ],
86+
87+ // Models that can be used for visibility rules
88+ 'visibility_models' => [
89+ // \App\Models\Content::class,
90+ // Add any models you want to use in visibility conditions
91+ ],
8692];
8793```
8894
@@ -164,13 +170,113 @@ When no other fields are available for dependency rules, the field selection wil
164170
165171#### Visibility Rules
166172
167- Control when fields are shown or hidden based on conditions:
173+ Control when fields are shown or hidden based on conditions. The visibility system supports two types of conditions:
174+
175+ ##### Field-Based Conditions
176+
177+ Show/hide fields based on other field values in the same form:
178+
179+ - ** Field Selection** : Choose from available fields in the current form
180+ - ** Dynamic Options** : Field options update automatically based on available fields
181+ - ** Self-Exclusion** : Fields cannot reference themselves to prevent infinite loops
182+
183+ ##### Model Attribute Conditions
168184
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
185+ Show/hide fields based on properties of the current record:
172186
173- The visibility system works seamlessly with validation rules to create intelligent, user-friendly forms.
187+ - ** Record Properties** : Access any attribute of the current model instance
188+ - ** Model Selection** : Choose from configured models in your application
189+ - ** Attribute Discovery** : Automatically discover available attributes from database schema
190+
191+ ##### Configuration
192+
193+ To enable model attribute conditions, add your models to the ` visibility_models ` config array:
194+
195+ ``` php
196+ return [
197+ // ... other config
198+
199+ // Models that can be used for visibility rules
200+ 'visibility_models' => [
201+ // \App\Models\Content::class,
202+ ],
203+ ];
204+ ```
205+
206+ ##### Supported Operators
207+
208+ The visibility system supports a comprehensive set of comparison operators:
209+
210+ - ** Equality** : ` equals ` , ` not_equals `
211+ - ** Text Operations** : ` contains ` , ` not_contains ` , ` starts_with ` , ` ends_with `
212+ - ** Empty Checks** : ` is_empty ` , ` is_not_empty `
213+ - ** Numeric Comparisons** : ` greater_than ` , ` less_than ` , ` greater_than_or_equal ` , ` less_than_or_equal `
214+ - ** List Operations** : ` in ` , ` not_in ` (comma-separated values)
215+
216+ ##### Logical Operators
217+
218+ Combine multiple conditions with logical operators:
219+
220+ - ** AND Logic** : All conditions must be met for the field to be visible
221+ - ** OR Logic** : Any condition can be met for the field to be visible
222+
223+ ##### Example Use Cases
224+
225+ ** Content Type-Based Fields** :
226+ ``` json
227+ {
228+ "logic" : " AND" ,
229+ "conditions" : [
230+ {
231+ "source" : " model_attribute" ,
232+ "model" : " App\\ Models\\ Content" ,
233+ "property" : " type_slug" ,
234+ "operator" : " equals" ,
235+ "value" : " article"
236+ }
237+ ]
238+ }
239+ ```
240+
241+ ** Multi-Condition Logic** :
242+ ``` json
243+ {
244+ "logic" : " OR" ,
245+ "conditions" : [
246+ {
247+ "source" : " model_attribute" ,
248+ "model" : " App\\ Models\\ Content" ,
249+ "property" : " status" ,
250+ "operator" : " equals" ,
251+ "value" : " published"
252+ },
253+ {
254+ "source" : " field" ,
255+ "property" : " field_ulid_here" ,
256+ "operator" : " equals" ,
257+ "value" : " draft"
258+ }
259+ ]
260+ }
261+ ```
262+
263+ ** Hide on Specific Pages** :
264+ ``` json
265+ {
266+ "logic" : " AND" ,
267+ "conditions" : [
268+ {
269+ "source" : " model_attribute" ,
270+ "model" : " App\\ Models\\ Content" ,
271+ "property" : " slug" ,
272+ "operator" : " not_equals" ,
273+ "value" : " home"
274+ }
275+ ]
276+ }
277+ ```
278+
279+ The visibility system works seamlessly with validation rules to create intelligent, user-friendly forms that adapt to your data and user interactions.
174280
175281### Making a resource page configurable
176282
@@ -382,6 +488,10 @@ The package includes a powerful Rich Editor with custom plugins:
382488
383489- ** [ Jump Anchor Plugin] ( docs/jump-anchor-plugin.md ) ** - Add anchor links to selected text for navigation and jumping to specific sections
384490
491+ ### Field Configuration
492+
493+ - ** [ Visibility Rules] ( docs/visibility-rules.md ) ** - Comprehensive guide to controlling field visibility based on conditions and record properties
494+
385495## Testing
386496
387497``` bash
0 commit comments