Search code examples
templatestwigoctobercms

How to get value from checkbox list in October CMS custom plugin


I entered project_toolbox into my plugin's database table and created checkbox list named project_toolbox with 10 values. How can I retrieve those value if checked from the backend.

Here is what I was unable to get the value of the checkbox value

<div class="project-toolbox">
{% for toolbox in project.project_toolbox %}
    <div class="{{ option.name }}"><span>{{ toolbox.name }} Hello</span></div>
{% endfor %}
</div>

enter image description here


Solution

  • You can simply iterate through array

    <div class="project-toolbox">
    {% for toolbox_item in project.project_toolbox %}
        <div class="{{ option.name }}"><span>{{ toolbox_item }} Hello</span></div>
    {% endfor %}
    </div>
    

    You can directly use string value {{ toolbox_item }} as project_toolbox is the array of strings.

    if any doubt please comment.