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.

unexpected conditional behavior with statuses

May 19, 2012 2:30pm

Subscribe [2]
  • #1 / May 19, 2012 2:30pm

    susanfw

    62 posts

    I have a status group that includes the following statuses open|closed|Active for 2012-2013|Pending Approval|Inactive. My members do not have access to open & closed, but have access to the others. I have a default status set in the Safecracker module.

    In my Safecracker template, I have the following conditional:

    {if status == "Inactive"}<input name="status" type="hidden" value="Pending Approval"/> {/if}

    So if an entry’s status is Inactive, I want it to change to Pending Approval on submit.

    I have an entry, whose status is Inactive. But, when I am logged in as a member and I submit the safecracker form for that entry, the status gets changed to ‘closed’.

    And oddly, if I change the conditional to read:

    {if status != "Inactive"}<input name="status" type="hidden" value="Pending Approval"/> {/if}

    saying the status does not equal Inactive, when I submit, it changes to ‘Pending Approval’, the opposite of what should happen.

    I tried putting the input statement in an embed, and also the whole conditional, but the result was the same.

    Also, if relevant, I have status=“Active for 2012-2013|Pending Approval|Inactive” included in the parameters.

    I’m using EE 2.4.0 and Safecracker 2.1

    What am I missing here?
    Thanks
    Susan

  • #2 / May 21, 2012 6:46am

    John St-Amand

    865 posts

    I’ve encountered something similar before - my first recommendation would be to verify that your spelling of your custom status is identical in-template as it is in the status group. In my case, a mis-match of the capitalization caused the same issue.

  • #3 / May 21, 2012 10:04am

    susanfw

    62 posts

    Thanks for your suggestion, John. It is the correct spelling including capitalization. I even checked it in the database tables. I also just tried changing it to a simple ‘pending’ and ‘inactive’ and the same thing happened.

    Susan

  • #4 / May 21, 2012 10:49am

    Bhashkar Yadav

    727 posts

    Hi Susan,

    Everything seems fine to me. Could you please check once by removing the space from the status “Pending Approval” i.e put it like “Pending_Approval”.


    Best Regards,

  • #5 / May 21, 2012 7:16pm

    susanfw

    62 posts

    Hi Bhashkar -
    Still not working. Here is my stripped down template:

    {exp:safecracker channel="schools" return="schools/school-update/ENTRY_ID" entry_id="{segment_3}" status="pending_approval|inactive"}
    {if status == "inactive"}<input name="status" type="hidden" value="pending_approval"/> {/if}
    <input type="text" name="title" id="title" value="{title}" size="40" maxlength="50"></td>
    <input type="submit" class="yellow_submit" id="submit2" name="submit2" value="SUBMIT" /> 
    {/exp:safecracker}

    It works if I change == to != , but then it’s doing the opposite of what I’m telling it, and I’m concerned if this is a bug, I’ll have a problem down the line.

    Susan

  • #6 / May 21, 2012 10:55pm

    Bhashkar Yadav

    727 posts

    Hi Susan,

    it seems there is a little missing. You are passing status parameter status=“pending_approval|inactive” into SafeCraker tag and also putting a hidden field for it.

    Please do few things:

    - Remove status=“pending_approval|inactive” from within exp:safecracker tag, because it also prepare a status hidden field.
    - manage the status with if condition like

    {if status == "inactive"}
    <input name="status" type="hidden" value="pending_approval" />
    {if:else}
    <input name="status" type="hidden" value="inactive" />
    {/if}

    - after prepare the form, please check the status hidden field value into HTML source if it’s correct and having status value according to condition.
    - in the case you are still facing problem please put if condition like {if "{status}” == “inactive”} and check the status field value into HTML source.

    Hope it would you. Also please let me your findings over it.


    Best Regards,

  • #7 / May 22, 2012 10:35am

    susanfw

    62 posts

    Removing the status parameter did the trick! Thanks so much Bhashkar. I looked at that line for so long and just didn’t see it.

    Susan

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

ExpressionEngine News!

#eecms, #events, #releases