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.

category selected into edit form

April 30, 2011 2:40am

Subscribe [3]
  • #1 / Apr 30, 2011 2:40am

    Marcuse

    166 posts

    Goodmorning, I have into my safecracker SAEF-form this code:

    {exp:channel:categories channel="nieuws" style="linear"}
    <input type="radio" name="category[]" value="{category_id}"  />  {category_name}
    
    {/exp:channel:categories}

    For the entry it’s working fine but for the edit it doesn’t display the choosing category how can I do this

    So the selected code must have: checked=“checked”

    <input type="radio" name="category[]" value="{category_id}" {if category =="???"}checked="checked" />{/if}  {category_name}
    

    Maybe it’s not possible?

  • #2 / May 02, 2011 4:15pm

    Brandon Jones

    5500 posts

    Hi Marcuse,

    Take a look at this thread. Does that help?

  • #3 / May 03, 2011 7:49am

    Marcuse

    166 posts

    I tried but No

    {exp:channel:categories channel="nieuws" style="linear"}
    <input type="checkbox" name="category[]" value="{category_id}" {if {selected}}checked=“checked”{/if} />  {category_name}
    
    {/exp:channel:categories}

    Gives no result when I edit the entry and it’s category is selected into the back-end

  • #4 / May 03, 2011 8:02am

    Marcuse

    166 posts

    Use this one instant, no boxes or buttons but works fine

    <select name="category[]" id="main_category" size="1">
        <option value="">-- Select a Category --</option>
        {exp:query sql="SELECT
                            c.cat_id,
                            c.cat_name,
                            p.selected
                        FROM
                            exp_categories AS c LEFT JOIN
                            (
                                SELECT cat_id, 'selected' AS selected FROM exp_category_posts WHERE entry_id='{entry_id}'
                            ) AS p ON c.cat_id=p.cat_id
                        WHERE
                            c.parent_id='0' AND
                            c.group_id='3'
                        ORDER BY c.cat_order ASC;"}
            <option value="{cat_id}" {if selected == "selected"}selected="selected"{/if}>{cat_name}</option>
        {/exp:query}
    </select>
  • #5 / May 04, 2011 11:26am

    Sue Crocker

    26054 posts

    Hi, Marcuse.

    It looks like this fixes your problem, just wanted to be sure before closing the thread…

  • #6 / May 04, 2011 11:40am

    Marcuse

    166 posts

    yes, thanks

  • #7 / May 04, 2011 4:30pm

    Sue Crocker

    26054 posts

    Great! Feel free to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases