Hi wondering if this is possible. I have a custom checkbox field for user interests added to the user profile. Is there a way to populate the checkbox options dynamically using tag data?

  • Any reason why you couldn't just use a Tags field? Apr 22 '15 at 11:02
  • The data is going to be used on the front end so users can use checkboxes to select what they are interested in but using tag data as their selection choice so not sure a tag field will work.
    – Lettie
    Apr 22 '15 at 11:09

I don't have enough reputation to post this as a comment, but this should help you pull the data on the front end with the LJ Dynamic Fields plugin.

Install the LJ Dynamic Fields plugin.

Create a 'Checkboxes (dynamic)' field with the following code:

{% for tag in craft.tags %}
   { "value":"{{ tag.id }}" , "label":"{{ tag }}" }
   {% if not loop.last %},{% endif %}
{% endfor %}

Front-end template code:

{% for tag in craft.tags %}
    <label>{{ tag }}</label>
    <input type="checkbox" value="{{ tag.id }}" {{ tag.id in entry.myCheckboxesDynamicField ? 'checked="checked"' }}>
{% endfor %}
  • No need to post as a comment... This is a legit answer! :)
    – Lindsey D
    Apr 22 '15 at 22:46

Not tested. But it would seem to me that you could use a tags field on the backend, and a checkbox field on the front-end (built dynamically from the tags). To submit the data you could either: format the data on the front-end via javascript before form submission, or submit to a custom plugin controller that converts the checkbox data format to the expected tags format, before saving.

Unfortunately, I can't tell you what the proper format for submitting tag data is from a form (I assume an array of tagIds?). If anyone knows please leave a comment and I'l update the answer (or feel free to edit the answer yourself). Might even be as simple as setting the option values to the tagId values — idk.


There's plugin for populating fields with dynamic data: Dynamic Fields. But I'm not sure if it works, when pulling data from the same entry you're rendering the field into.

  • cheers will take a look at it. First glance would suggest it does what I need.
    – Lettie
    Apr 22 '15 at 11:38
  • Plugin works great on the back-end and populates the fields with data from tags. However it does not work on the front-end when pulling out the data. I've spoke to Lewis who created the plugin and he was very helpful but says he needs to look into and adjust the plugin to do this. So currently it won't do what I require.
    – Lettie
    Apr 22 '15 at 14:50
  • @Lettie Since I last spoke to you I came up with a solution which I've posted as an answer. Apr 23 '15 at 9:12

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.