We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Channel Forms: Creating Different Inputs Fields for Different Category Groups

How Do I?

cooperdjm72's avatar
cooperdjm72
16 posts
3 years ago
cooperdjm72's avatar cooperdjm72

So I have a channel form for editing Entries. There are two different categories assigned to the channel: Department (category_groups ID 12) VLANs (category_groups ID 6)

I want the user to select a category from different Select lists.

In the channel form I have the following code:

        {category_menu show_group="12"}
        Department
        <select name="category[]" id="categories" size="4" multiple="multiple">
          {select_options}
        </select>
        {/category_menu}


        {category_menu show_group="6"}
        Vlans
        <select name="category[]" id="categories" size="4" multiple="multiple">
          {select_options}
        </select>
        {/category_menu}

When the Page is loaded both the above select menus are populated with the Last Category Group to load options, in this case, VLANS group6

I feel I must be missing something very obvious.

Any Ideas. I attached a screenshot of how the template loads

       
Rob Allen's avatar
Rob Allen
3,105 posts
3 years ago
Rob Allen's avatar Rob Allen

Have you tried using the plain {categories}{/categories} tag pair instead of {category_menu}{/category_menu} ?

       
cooperdjm72's avatar
cooperdjm72
16 posts
3 years ago
cooperdjm72's avatar cooperdjm72

Hi, thanks for the reply but {categories}{/categories} pair seem don’t work in Channel Forms at all. They seem to only be for Channel Entries

       
seavers's avatar
seavers
20 posts
3 years ago
seavers's avatar seavers

Just a thought, but sometimes when dealing with Categories a gotcha is that if you have no entries assigned to a category, it doesn’t show. From memory neither does the group if no entries are assigned to that group.

This has bitten me numerous times when developing new functionality.

       
cooperdjm72's avatar
cooperdjm72
16 posts
3 years ago
cooperdjm72's avatar cooperdjm72

@seavers Thanks I will try that and let you know.

Unfortunately, that has had no impact. The Channel form still parses both input fields with the last Coded category group. So odd.

       
cooperdjm72's avatar
cooperdjm72
16 posts
3 years ago
cooperdjm72's avatar cooperdjm72

So it seems to be an issues with the Multiselect list input field. This format checkbox works:

        <h5>Department Category</h5>
        {categories show_group="6"}
          <input type="checkbox" name="category[]" id="{category_name}" value="{category_id}"{checked}> {category_name}<br>
        {/categories}
        <h5>Vlan Category</h5>
        {categories show_group="12"}
          <input type="checkbox" name="category[]" id="{category_name}" value="{category_id}"{checked}> {category_name}<br>
        {/categories}
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.