2

I want to show or hide the status option based on the current status in a safecracker form. This because i want that people can edit statuses form entries which are open or closed, but not the one who are denied.

So far no success because safecracker doesn't like the IF statement, i think i can do it with jquery but is there a good EE solution to get the result i want?

{exp:safecracker 
     channel="nieuws" 
     return="profiel/nieuws" 
     entry_id={segment_3}"
     author_only="yes" 
     error_handling="inline" 
     status="open|closed|denied"}

{if status=="denied"}
    Can't change the status
{if:else}
    <label for="status">Status</label>
    <select name="status" id="status">
        <option value="open">Open</option>
        <option value="closed">Closed</option>
    </select>
{/if}
1

You can try what Anna suggested. While editing an entry via Safecraker, its populate all the variables of channel entries within safecraker tag so {status} variable also be populated as well.

Also, while looking at your code it seems that you are missing opening double quote while passing parameter entry_id.

Check it.

| improve this answer | |
  • Thank you for noticing that, i think this is happend while edit the code over here. But no luck with Anna's example. – Eddyfever Mar 3 '13 at 19:12
0

Try this instead;

{if "{status}" =="denied"}
    Can't change the status
{if:else}
    <label for="status">Status</label>
    <select name="status" id="status">
        <option value="open">Open</option>
        <option value="closed">Closed</option>
    </select>
{/if}
| improve this answer | |
  • Thank you for the try, but so far no luck. But it get the way you where thinking. – Eddyfever Mar 3 '13 at 19:11
  • What does {status} print out inside the exp:safecracker tags? Is it perhaps "Denied" with a capital D? – Anna_MediaGirl Mar 3 '13 at 20:05
  • Yeh it was with a capital, i double checked so that i was sure that Denied = Denied. Other thing i found out is, when i use !="open" (or closed) then it generates then the text before if:else on all pages (also the open entries. When i use {status}=="denied" then it generates the code after if:else on all entries. Pretty strange i think. – Eddyfever Mar 3 '13 at 20:15
  • So all sorted? If yes, please select my answer as correct by clicking on the checkmark to the left... – Anna_MediaGirl Mar 3 '13 at 20:17
  • Sorry no it isn't. I see now that my last comment is a bit confused. It was "yeh" that i checked the capital. – Eddyfever Mar 3 '13 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.