1

I have an asset field (craft\fields\Asset), how do I figure out which Sources it can use? (Which of the Sources boxes are checked)?

This is for Craft 3, and I'd like to do it in twig (I have the asset field in twig)

2

You can get all available sources with

field.getSourceOptions()

Which returns you an array of all sources, no matter if they are selected or not (just to get the ids and such)

and with

field.sources

you'll receive an array if you selected several sources or a string (*) if all are selected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.