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 if conditions based on published input

May 18, 2012 10:42am

Subscribe [3]
  • #1 / May 18, 2012 10:42am

    Eastwood Design

    605 posts

    I have a 2 step safecracker form

    First I ask them a job type.  Ie: type A, type b etc (from a multi select field)

    they submit the form and publish to the channel

    next page they are shown the form the entry they just submitted and asked some details about that job.

    how can I ask particular questions based on the previous answer?

    {exp:safecracker channel="connection" return="video/thanks" entry_id="{segment_3}"}
    <input name="title" type="hidden" value="{member_id} - {username}">
    Which best describes your work?
    
    {if connection == "Education Services"}Teacher, lecturer, Asst/ Assoc/ Professor, Teaching assistant , home schooling parent, other{/if}
    <input type="text" name="connection2" id="connection2" value="{connection2}">
         
    
    
    
       <input type="submit" value="Submit">
    {/exp:safecracker}
  • #2 / May 18, 2012 11:54am

    Rob Allen

    3114 posts

    As you’re essentially publishing a new entry and if you have an entryID in the URL you should be able to use a Channel entries tag to pull in the value.

    Something like this:

    {exp:safecracker channel="connection" return="video/thanks"}
    <input name="title" type="hidden" value="{member_id} - {username}">
    Which best describes your work?
    
    
    {exp:channel:entries channel="channel_name" limit="1" entry_id="{segment_3}" 
    search:your_field="Education Services" status="open|pending"}
    Teacher, lecturer, Asst/ Assoc/ Professor, Teaching assistant , home schooling parent, other{/exp:channel:entries}
    
    <input type="text" name="connection2" id="connection2" value="{connection2}">
         
    
    
    
       <input type="submit" value="Submit">
    {/exp:safecracker}
  • #3 / May 18, 2012 12:00pm

    Eastwood Design

    605 posts

    would this also work if I am editing the first entry?

    lets say my channel has 2 fields.  They enter the info for the first field on the first form, then submit, then they edit the same entry on the second form and add the details for the second filed, based on their answer from the first field

  • #4 / May 18, 2012 12:05pm

    Rob Allen

    3114 posts

    Hmmm sort of.

    On the first step they would be publishing a *new* entry, once that’s saved and added to the database you’re the editing the same entry, so in that case you’d need to call the segment_id into the safecrcaker tag as well, something like this may work:

    {exp:safecracker channel="connection" return="video/thanks" entry_id="{segment_3}"}
    <input name="title" type="hidden" value="{member_id} - {username}">
    Which best describes your work?
    
    
    {exp:channel:entries channel="channel_name" limit="1" entry_id="{segment_3}" 
    search:your_field="Education Services" status="open|pending"}
    Teacher, lecturer, Asst/ Assoc/ Professor, Teaching assistant , home schooling parent, other
    {/exp:channel:entries}
    
    <input type="text" name="connection2" id="connection2" value="{connection2}">
         
    
    
    <input type="submit" value="Submit">
    
    {/exp:safecracker}
  • #5 / May 18, 2012 12:16pm

    Eastwood Design

    605 posts

    thanks!!  this is great!

  • #6 / May 21, 2012 11:23am

    Shane Eckert

    7174 posts

    Hey Eastwood Design,

    Glad to see that Rob was able to help you out! Nice work guys!! This is a good solution.

    If you need anything else, please just let us know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases