1

Primary Category, when used with Channel Forms as per these instructions: http://www.solspace.com/docs/primary_category/using_with_channel_form/, does not function as expected.

The problem is that the {category}{/category} tags make all selected categories {selected}, even if they are not the single selected Primary Category. So the select box for the Primary Category selection has multiple selected options, which of course is not allowed in HTML and so it often highlights the incorrect value as the selected one.

Is there another way, other than using the {selected} variable, to select only the single Primary Category in this category select box? Otherwise it can't function reliably in Channel Forms unless each entry is assigned to only a single category.

1 Answer 1

1

The solution to this, graciously supplied by Solspace, is to use an exp:primary_category tag inside each select option to check if it's the selected primary category:

<select name="primary_category">
        {categories}
            <option value="{category_id}" {exp:primary_category entry_id="{entry_id}"}{if '{category_id}' == '{primary_category_id}'}selected="selected"{/if}{/exp:primary_category}>
                {category_name}
            </option>
        {/categories}
</select>

Hopefully they'll update their docs so this issue doesn't come up again.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.