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.

{parent_id} support within Safecracker {categories} loop - where did it go?

June 18, 2012 7:50am

Subscribe [3]
  • #1 / Jun 18, 2012 7:50am

    ipixel (Australia)

    158 posts

    I have a Zoo Visitor (aka Safecracker) registration form with was working great up until a couple of days ago when I upgraded EE from v2.1.3 to v2.5.2. I thought that all would be good to go, but now the crucial part of the registration form (which is for an association) is completely busted (well it just doesn’t render) as the {parent_id} variable within the Safecracker {categories} group is no longer accessible.

    This has been tested to be so in both a Safecracker form and a Zoo Visitor form. When I try to just render out the {parent_id} parameter, all I get is the tag printed, not the value of it.

    Test page can be seen here:
    http://www.profilmcrewwa.com.au/sandbox

    And here’s my template code which was working fine in v2.1.3:

    {exp:safecracker channel="profile" return='success'}
    
      {categories group_id="1"}
      
        {!--print this >>> --}{parent_id}
        {if '{parent_id}' == '0'}
          <h4>{category_name}</h4>
    <p>    {/if}<br />
        {if '{parent_id}' != '0'}<br />
          <input class="checkbox required" type="checkbox" value="{category_id}" name="category[]" id="specialty-{category_id}" {checked}> <br />
          <label class="checkbox" for="specialty-{category_id}">{category_name}</label><br><br />
        {/if}</p>
    
    <p>  {/categories}<br />
            <br />
    {/exp:safecracker}

    Can someone urgently get back to me on this as the client is needing to run a registration campaign drive for new members and without this form it’s kind of useless.

  • #2 / Jun 19, 2012 12:42pm

    Shane Eckert

    7174 posts

    Hey sillbeer,

    I am sorry to hear you are running into this problem.

    Just want to make sure that you updated Zoo Visitor. I know you probably did, but wanted to cover that base first.

    Is SafeCracker in the Third Party folder? If it is, it could be in conflict with SafeCracker in Modules, which was a change between the two versions.

    Also, SafeCracker File in Third Party needs to be updated and sometimes is not because of drag and drop.

    Can you check these things and get back to me?

    Thank you,

  • #3 / Jun 19, 2012 8:11pm

    ipixel (Australia)

    158 posts

    Hi Shane

    I have checked and I’m using v2.1 of Safecracker which is located in the modules folder (nothing in third_party), and Safecracker File was updated with the new version (v2.1) of EE (I didn’t bring the old version across when I moved the third_party addons). Zoo Visitor is using the latest v1.30 so everything is using the latest.

    OK, what next.

    Cheers
    Brendan

  • #4 / Jun 20, 2012 3:44pm

    ipixel (Australia)

    158 posts

    Any more luck into finding anything out on this Shane?

  • #5 / Jun 20, 2012 4:09pm

    Shane Eckert

    7174 posts

    Hi sillbeer,

    I talked with a few folks about this. Things have changed enough in version 2 that you must use channel tags to get the parent_id.

    I tried wrapping the block in {exp:channel:categories} tags instead categories and it worked for me.

    Can you give that a try and let me know?

    Cheers,

  • #6 / Jun 20, 2012 4:16pm

    ipixel (Australia)

    158 posts

    My concern would be whether or not when they are editing their profile, if the checkboxes get checked or not. Pretty disappointed that this was there, and now it’s not. I was relying heavily on it to determine how to print for display.

  • #7 / Jun 20, 2012 4:23pm

    Shane Eckert

    7174 posts

    Hey sillbeer,

    One way to do that is to use the array similar to this, but you would not be able to print the parent_id with this method.

    {categories}
      <label for="{category_name}">{category_name}</label>
      <input type="checkbox" name="category[]" id="{category_name}" value="{category_id}"{checked}>
    {/categories}

    If you want, I can move this to development and programming, there may be some more insight or a custom way to accomplish this that the community can give you some tips on.

    Cheers,

  • #8 / Jun 20, 2012 4:37pm

    ipixel (Australia)

    158 posts

    Thanks for the code snippet, but as you can see from http://www.profilmcrewwa.com.au/sandbox, I really need the parent_id to style and change what’s being displayed.

    It was a variable available previously, which was working fine, and with an update it broke. Now my client is left with a form that if we use it the way you’re saying will have a list of categories with no structure to it as per the actual categories that have been set within EE. For EL to say that ‘things have changed’ just doesn’t cut it I’m afraid especially as this was working in EE v2.1.3.

    Can this be escalated in any way so that functionality can be brought back in that was lost?

  • #9 / Jun 20, 2012 4:53pm

    Shane Eckert

    7174 posts

    Hey

    I think there is a misunderstanding here, and I am sorry about that.

    All you have to do is add the channel tags. (and preserve_checkboxes)

    {exp:channel:categories}
        {if '{parent_id}' == '0'}
          <h4>{category_name}</h4>
    <p>    {/if}<br />
        {if '{parent_id}' != '0'}<br />
          <input class="checkbox required" type="checkbox" value="{category_id}" name="category[]" id="specialty-{category_id}" {checked}> <br />
          <label class="checkbox" for="specialty-{category_id}">{category_name}</label><br><br />
        {/if}<br />
    {/exp:channel:categories}

    Can you try that and tell me what the results are?

    I can also take this into private support, get a login and see what I can do myself if that is helpful. But I would that think the above code block would do what you are looking for.

    Cheers,

  • #10 / Jun 20, 2012 5:15pm

    ipixel (Australia)

    158 posts

    Thanks for the template code, unfortunately even with the preserve checkboxes in there, I’m not able to ‘Edit’ and existing entry/profile and see currently checked boxes.

  • #11 / Jun 21, 2012 3:43pm

    Shane Eckert

    7174 posts

    Hey sillbeer,

    Please be on the lookout for an email from EllisLab.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases