Open RobertCordes opened 4 years ago
What if you add a field of type: hidden
to your blueprint called view_model
with as a default: App\ViewModels\TheOneYouWant
?
I think this belongs in the ideas repo as a FR. I think you mentioned you can move issues @jackmcdade?
Yeah that would be my fallback solution.
Feel free to move this issue if it isn’t a bug 😊 I can also just close this and create a FR.
Yeah cool, please add it as a FR!
Sorry for the double post. @jasonvarga was faster transferring this issue than me posting it here as a FR.
Bug Description
No matter how I try to set a view model for a specific blueprint, I can't get it to work. I've searched all over the place but I can't find a solution. There only seem to be two ways: in the collection (via
inject
) or directly in the markdown file of a specific page.How to Reproduce and extra details
The documentation only gives one example of where to specifiy your view model — inside a collection by using
inject
:And that works as expected. In my pages collection I have different blueprints, for example
homepage.yaml
,about.yaml
, etc. I’m expecting that I can just as well define view models inside those files:Reading the documentation on view models, I didn't expect this to be a problem. I also tried using YAML front matter inside the template:
What does work however is defining the view model inside the markdown files:
I don't know if this is a bug or not, but it's definitely not very intuitive. If it it expected behaviour this can obviously be closed. 😇
Environment
Statamic 3.0.8 Pro Laravel 7.25.0 PHP 7.4.2 rias/statamic-color-swatches 2.0.5
Install method: Fresh install from
statamic/statamic