Is there a way to get raw/unformatted values for a field before they're passed to the field's normalizeValue
function? That is, get the value close to how it's stored in the database? I haven't found a documented method for this in the documentation.
Background
I'm building a section with a categories field, the selected categories act as filters for an entries feed that is displayed on the frontend for that entry. So I'm doing something like this:
{% set selectedCategories = entry.my_categories_field.ids() %}
{% set entriesFeed = craft.entries().relatedTo(selectedCategories).all() %}
But the additional database query is kind of pointless. As far as I know, the categories field already stores the selected categories as a list of IDs – correct me if I'm wrong. So when the field is accessed, it returns a CategoryQuery
populated with a filter to match those IDs. Then I execute that query with .ids()
just to get the IDs from the database that are already stored in the field in the first place.
Is there a simple way to get the stored IDs for that field directly without an additional database query? I.e., the value before its normalized to a CategoryQuery by normalizeValue
?