I have a usecase where I would like to access the current block in a field. E.g. the custom my-field acts on the value of another field. I specify this relation by providing a query that should point to another field within the same block:
// my-field.php
return [
// ...
'computed' => [
'text' => function() {
// Should return the value of the writer field
return $this->model()->query($this->attrs['query'])->value();
}
]
];
But it seems that only site, page and file are available to query, not block. Is there maybe any workaround?
I think the big problem is that a field doesn’t know anything about it’s whereabouts. No matter if it lives within a page blueprint, a block blueprint, a structure, the model is always the page.
Agree that this would be useful, but the problem is that this would have to happen on the frontend, when the value of the pages field changes. The backend blueprint doesn’t know anything about your frontend.