ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

SafeCracker Category order

November 29, 2011 3:37pm

Subscribe [1]
  • #1 / Nov 29, 2011 3:37pm

    I am building a front end entry form and I would like to provide categories as a list and not a multi select similar to the back end form.

    I get all the categories to display as check boxes but the sort order is all messed up.

    Here is my safecracker code

    <ul>
    {categories group_id="9"}
        {if '{parent_id}' == '0'}<h4 class="toggle-next">{category_name}</h4>{/if}
        {if '{parent_id}' != '0'}<li><input class="checkbox required" type="checkbox" value="{category_id}" name="category[]" id="categories"><label>{category_name}</label></li>{/if}
      {/categories}
    </ul>

    Here is how it outputs: Notice that the sort order is not alpha and it is also not my custom order specifies in the CP

    <ul>
      
        <h4 class="toggle-next">Advocacy, Policy, Systems & Environmental Change</h4>      
    
            <li><input type="checkbox" value="28" name="category[]" id="categories"/><label>Aerobics & Fitness Classes</label></li>  
    
            <li><input type="checkbox" value="34" name="category[]" id="categories"/><label>Acupuncture & Oriental Medicine</label></li>  
    
            <li><input type="checkbox" value="45" name="category[]" id="categories"/><label>Cancer</label></li>  
    
            <li><input type="checkbox" value="54" name="category[]" id="categories"/><label>Community Supported Agriculture</label></li>  
    
            <li><input type="checkbox" value="26" name="category[]" id="categories"/><label>Canoe Clubs</label></li>  
    
        <h4 class="toggle-next">Complimentary & Alternative Medicine</h4>      
    
            <li><input type="checkbox" value="39" name="category[]" id="categories"/><label>Childbirth Education & Care</label></li>  
    
            <li><input type="checkbox" value="46" name="category[]" id="categories"/><label>Diabetes</label></li>  
    
            <li><input type="checkbox" value="53" name="category[]" id="categories"/><label>Cooking & Caterers</label></li>  
    
            <li><input type="checkbox" value="22" name="category[]" id="categories"/><label>Children</label></li>  
    
            <li><input type="checkbox" value="32" name="category[]" id="categories"/><label>Chiropractic</label></li>  
    
        <h4 class="toggle-next">Conditions & Diseases</h4>      
    
            <li><input type="checkbox" value="44" name="category[]" id="categories"/><label>Energy Medicine</label></li>  
    
            <li><input type="checkbox" value="55" name="category[]" id="categories"/><label>Farmers Markets</label></li>  
    
            <li><input type="checkbox" value="27" name="category[]" id="categories"/><label>Dance, Nia, Zumba </label></li>  
    
            <li><input type="checkbox" value="36" name="category[]" id="categories"/><label>Colon Hydrotherapy</label></li>  
    
            <li><input type="checkbox" value="47" name="category[]" id="categories"/><label>Heart Disease</label></li>  
    
        <h4 class="toggle-next">Healthy Eating</h4>      
    
            <li><input type="checkbox" value="52" name="category[]" id="categories"/><label>Farms & Ranches</label></li>  
    
            <li><input type="checkbox" value="29" name="category[]" id="categories"/><label>Gyms, Clubs & Trainers</label></li>  
    
            <li><input type="checkbox" value="38" name="category[]" id="categories"/><label>Herbal Medicine</label></li>  
    
            <li><input type="checkbox" value="48" name="category[]" id="categories"/><label>HIV, AIDS</label></li>  
    
            <li><input type="checkbox" value="56" name="category[]" id="categories"/><label>Gardens School & Community</label></li>  
    
        <h4 class="toggle-next">Tobacco Cessation</h4>      
    
            <li><input type="checkbox" value="30" name="category[]" id="categories"/><label>Martial Arts </label></li>  
    
            <li><input type="checkbox" value="42" name="category[]" id="categories"/><label>Life Coaching</label></li>  
    
            <li><input type="checkbox" value="51" name="category[]" id="categories"/><label>Kidney Disease</label></li>  
    
        <h4 class="toggle-next">Worksite Wellness</h4>      
    
            <li><input type="checkbox" value="23" name="category[]" id="categories"/><label>Sporting Activities</label></li>  
    
            <li><input type="checkbox" value="40" name="category[]" id="categories"/><label>Massage, Bodywork</label></li>  
    
            <li><input type="checkbox" value="57" name="category[]" id="categories"/><label>Nutrition Information/Education</label></li>  
    
            <li><input type="checkbox" value="25" name="category[]" id="categories"/><label>Walking, Running, Biking</label></li>  
    
            <li><input type="checkbox" value="33" name="category[]" id="categories"/><label>Naturopathic Physicians</label></li>  
    
            <li><input type="checkbox" value="50" name="category[]" id="categories"/><label>Weight Loss Resources</label></li>  
    
            <li><input type="checkbox" value="24" name="category[]" id="categories"/><label>Yoga & Pilates</label></li>  
    
            <li><input type="checkbox" value="35" name="category[]" id="categories"/><label>Retreats & Spa Therapies</label></li>  
    
            <li><input type="checkbox" value="41" name="category[]" id="categories"/><label>Stress Management </label></li>  
    
            <li><input type="checkbox" value="37" name="category[]" id="categories"/><label>Traditional Native Hawaiian Medicine</label></li>  
    
    
    </ul>

    Is this a know bug,  Is there a way to just code in the category options manually and not use a loop?

  • #2 / Jan 16, 2012 9:59pm

    Can EE give me any kind of support?  It has been a really long time since I posted this.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases