TransWikia.com

Looking to create a dropdown field to select an icon

Craft CMS Asked by tommysvr on September 4, 2021

I use the same icons across most of my projects, and typically just list them in Dropdown fields. However, this quickly becomes difficult to manage, so I’m looking to create a simple plugin that I can easily reuse.

I’ve started with pluginfactory.io to scaffold it out, selecting the Field Types component and installed via Composer but struggling from there.

  • How do I define the list of icons that should show in the dropdown field?
  • How do I get that to then reference the correct SVG file?
  • How do I output that properly in my templates with {{ entry.icon }}?

I realise that’s literally asking how to build this thing ? but I would appreciate some guidance!

One Answer

What you are describing sounds a lot like the Position Fieldtype. I would look at that plugin for guidance.

Answered by Marion Newlevant 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