TransWikia.com

craft.fields.getFieldByHandle() has been deprecated

Craft CMS Asked by Jon Goldman on September 4, 2021

I’m querying a dropdown field to loop through all of the options and followed best practice (so I thought) in the twig template. Does anyone know how to update for the deprecation below?

Deprecation message:

craft.fields.getFieldByHandle() has been deprecated. Use craft.app.fields.getFieldByHandle() instead.

Code line:
{% set siteOptions = craft.fields.getFieldbyHandle('siteSelector').settings.options %}

One Answer

You should replace craft.fields.getFieldbyHandle() with craft.app.fields.getFieldByHandle() (note the additional .app in there).

Correct answer by Oli on September 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP