I would like to link some categories to blog posts, but not all.
If I use the “entries” field (to link categories to blogs), I don’t feel like there is a way to add a condition to display only certain categories.
One solution would be to use a dynamic dropdown/checkbox field.
But then the problem is that the value is not considered as a relationship.
The only solution is to separate each group of categories into differents “entry”?
Thanks!
PS: The same problem arises if you want to use a “relational” field in a form field. Since the “entries” types do not seem to work (only dropdown/checkbox fields work)
Hello again, @MallauryGerard. We have investigated this requirement and added support for it October CMS v3.1.25. Also, the following has been added to the documentation:
Applying Conditions
You can restrict the related query using SQL or PHP using the approaches below. In the examples, the related record has a field called is_featured that renders as a checkbox. We can limit the related records to only those that have this checkbox marked.
SQL Query Condition
You may limit the related model using a raw SQL query using the conditions property.
I wonder if I do something wrong because it’s not working as expected for me. Maybe I understand the feature wrong.
I have a blueprint like the following for Features:
handle: Lists\Features
type: structure
name: Features
drafts: false
multisite: sync
pagefinder: false
structure:
maxDepth: 1
fields:
always_included:
label: Set this feature to always be include in all models
type: switch
default: false
translatable: false
In another blueprint, for the Models, I have a field using these Features. However, I don’t want to let the users select those features that are always included because, well, they are!
handle: Site\Models
type: stream
name: Models
drafts: false
multisite: sync
pagefinder: item
fields:
features:
label: Included features of the model
type: entries
source: Lists\Features
conditions: always_included = false
displayMode: taglist
translatable: false
I was expecting the condition to kick in and that the Features marked as “always included” would not appear in the Model’s taglist, but they do.