verbb / icon-picker

A Craft CMS field to select SVG or font icons from a folder for use in your content.
Other
17 stars 8 forks source link

URL to icon folder output when field is left empty #33

Closed proimage closed 4 years ago

proimage commented 4 years ago

Description

When I don't select an icon in the field, the output of {{ entry.iconPickerField }} is the absolute URL to the icon folder, eg. //localhost:3002/icons/svg. 😕

Steps to reproduce

  1. Add an Icon Picker field to a section field layout
  2. Edit an entry, leaving the Icon Picker field untouched.
  3. Output the value of the empty Icon Picker field in a template.

Additional info

engram-design commented 4 years ago

Fixed in 1.1.5

proimage commented 4 years ago

Hmm. I've updated, and while that fixes the actual output, there's still a problem with conditionals (which I thought was due to the output before). When I do {{ entry.iconPickerField|length }}, it returns a positive integer (9 in my test case) for empty fields instead of 0 (or null or whatever the "blank" value actually is).

engram-design commented 4 years ago

I'm concerned this will be a breaking change. I can easily return null as the value from the field, the issue is if people out there are using {{ entry.iconPickerField.icon }}, or one of the other many attributes of the model, their templates will break.

I will shelve this for a future major release. In the meantime, you'll need to use {{ entry.iconPickerField.length }}. Sorry for the hassle.

See 1.1.8

proimage commented 4 years ago

Ok, well that works for now. Thank you!!