<p>Something like the following should work. This assumes that your category field handle is 'jobCategory', and has a limit set to 1.</p>

<pre><code>{% set categories = craft.categories.group('jobCategory') %}
{% set entryCategory = entry.jobCategory.first %}
&lt;label for="fields[jobCategory]"&gt;Job Category:&lt;/label&gt;
&lt;select id="jobCategory" name="fields[jobCategory]"&gt;
    {% for category in categories %}
        &lt;option value="{{ category.id }}" {% if category.title == entryCategory %}selected{% endif %}&gt;{{ category.title }}&lt;/option&gt;
    {% endfor %}
&lt;/select&gt;
</code></pre>

CC BY-SA 3.0
2015-01-20T17:46:27.540Z
BOOM! Almost {% if category.title == entryCategory %} - if you update your answer, I'll accept it :)
Steven Grant
CC BY-SA 3.0
2015-01-20T17:53:14.713Z
@StevenGrant Updated for Douglas.
Brad Bell
CC BY-SA 3.0
2015-01-20T18:04:11.473Z
Close. Glad you got it working. (And thanks brad.)
Douglas McDonald
CC BY-SA 3.0
2015-01-20T17:03:28.400Z
2015-01-20T17:52:48.823Z
2015-01-20T17:52:48.823Z
Douglas McDonald
<p>I have this in my edit form</p>

<pre><code>{% set categories = craft.categories.group('jobCategory') %}
    &lt;label for="fields[jobCategory]"&gt;Job Category:&lt;/label&gt;
    &lt;select id="jobCategory" name="fields[jobCategory]"&gt;
        {% for category in categories %}
            &lt;option value="{{ category.id }}"&gt;{{ category.title }}&lt;/option&gt;
        {% endfor %}
    &lt;/select&gt;
</code></pre>

<p>but can't for the life of me, show select as 'selected' for the category the entry belongs to.</p>

<p>Missing something simple I'm sure.</p>

<categories><frontend><category><editor>
frontend editing, show selected category
# frontend editing, show selected category

(Asked by: username_0 on 2015-01-20)

I have this in my edit form
{% set categories = craft.categories.group('jobCategory') %}
    Job Category:
    
        {% for category in categories %}
            {{ category.title }}
        {% endfor %}
    

but can't for the life of me, show select as 'selected' for the category the entry belongs to.
Missing something simple I'm sure.

**Tags:** categories, frontend, category, editor


---

## 1 answers

### Answer by username_1 on 2015-01-20. Score: 2 | Accepted answer

Something like the following should work. This assumes that your category field handle is 'jobCategory', and has a limit set to 1.
{% set categories = craft.categories.group('jobCategory') %}
{% set entryCategory = entry.jobCategory.first %}
Job Category:

    {% for category in categories %}
        {{ category.title }}
    {% endfor %}

> **Comments:**
> **username_0**: BOOM! Almost {% if category.title == entryCategory %} - if you update your answer, I'll accept it :)  
> **username_2**: @StevenGrant Updated for Douglas.  
> **username_1**: Close. Glad you got it working. (And thanks brad.)  

---

