DrQuincy Posted June 7, 2021 Share Posted June 7, 2021 I have an Images field that is set to required, maximum file = 1 and Single item (null if empty). When I get the page in the front-end template the field if of ProcessWire\Pageimage (singular) type as I would expect but in a Pages::saveReady hook it is ProcessWire\Pageimages (plural). Is this excepted behaviour — and if so, why? Is it to do with PW applying the “Single item (null if empty)” further down the chain? Thanks. EDIT: I think I have found the answer. It says this in the back-end: Quote Select the type of value you want this field to provide when accessed from the API on the front-end of your site. I am assuming then that because the Pages::saveReady hook is called in the back-end this isn't applied. Instead, it is added some time before the template is loaded. So, fields Files and Images will always be arrays in the back-end/unless accessed via the templates. Is that right? Link to comment Share on other sites More sharing options...
Zeka Posted June 7, 2021 Share Posted June 7, 2021 2 Link to comment Share on other sites More sharing options...
DrQuincy Posted June 7, 2021 Author Share Posted June 7, 2021 That's confirmed what I thought, thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now