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 error_handling="inline" loosing field data

July 08, 2011 10:07am

Subscribe [2]
  • #1 / Jul 08, 2011 10:07am

    Matt Ellis

    51 posts

    Using a Safecracker form, when I set “error_handling=“inline”, the page refreshes and I get the error messages for each field, but I loose all the previously entered data.

    If I remove “error_handling=“inline” and let EE handle the form errors with a user message template, then click “Return to Previous Page”, all the previously entered data is still in place - which is the desired effect!

    Is this a bug or a setting I’ve missed?

    Thanks!

  • #2 / Jul 11, 2011 5:53am

    John Henry Donovan

    12339 posts

    Matthew,

    What version and build of EE are you using?
    Are you using any other add-ons?

    Can you pasted your template code here so we can try and replicate please?

  • #3 / Jul 11, 2011 12:28pm

    Matt Ellis

    51 posts

    Hi John,

    I’m using v2.2.1 - Build: date 20110630

    Add-ons: Structure / Accessible Capture (tested on/off) / Matrix / CE image / TrunHTML

    Here’s the bones of template code - which is causing the problem:

    {embed="includes/.header"}
    
        {exp:channel:entries channel="the_fridge_door" dynamic="off" orderby="random" limit="12" show_expired="yes" show_future_entries="yes" disable="categories|member_data|trackbacks|pagination"}
        
            {!-- CONTENT --}
            {content}
    
        {/exp:channel:entries}
        
        {!-- FORM --}
        {exp:safecracker channel="the_fridge_door" error_handling="inline" rules:tfd_name="required" rules:tfd_email="required" return="the-fridge-door"}
            
            {!-- PERSONAL --}
            <fieldset>
                <h1>About You</h1>
            
                
                <label for="tfd-name">Your Name<span class="req">*</span></label>
    
                <input name="tfd_name" id="tfd-name" class="text rc" type="text" /><br >
                <span class="small">(Required)</span>
                {if error:tfd_name}<span class="error">{error:tfd_name}</span>{/if}
                
            
                
                <label for="tfd-email">Your Email<span class="req">*</span></label>
    
                <input name="tfd_email" id="tfd-email" class="text rc" type="text" /><br >
                <span class="small">(Required) Will <strong>not</strong> be displayed on the site</span>
    
                {if error:tfd_email}<span class="error">{error:tfd_email}</span>{/if}
                
            
                
                <label for="tfd-url">Your URL</label>
    
                <input name="tfd_url" id="tfd-url" class="text rc" type="text" /><br >
                <span class="small">(Optional) Link to your website or Twitter page</span>
                
                     
    
                <label for="captcha">Prove your worth by answer the following riddle:</label>
    
                {captcha}
                <input type="text" name="captcha" id="captcha" value="{captcha_word}" maxlength="20" />
                <input type="submit" id="submit" value="Submit" class="button rc" />
    
                
                {!-- DYNAMIC TITLE (Hidden) --}
                <input name="title" id="title" class="text rc" type="hidden" value="The Fridge Door - {current_time format="%r"}" />
            
            </fieldset>
        
        {/exp:safecracker}
    
    {embed="includes/.footer"}
  • #4 / Jul 12, 2011 9:10pm

    Kevin Smith

    4784 posts

    Hey Matthew,

    For SafeCracker to re-populate the input fields after submitting an entry with errors in it, you need to have this added to each input:

    value="{field_name}"

    So your first input, for example, should look like this:

    <input name="tfd_name" id="tfd-name" class="text rc" type="text" value="{tfd_name}" />

    Does that take care of it for you?

  • #5 / Jul 18, 2011 3:22am

    Matt Ellis

    51 posts

    Thanks Kevin,

    RTFM springs to mind!

    All sorted now, thank you.

  • #6 / Jul 18, 2011 11:56am

    Lisa Wess

    20502 posts

    Glad you got this one working, Matthew!  If anything else comes up, please start a new thread and we can help out there.

    Thank you!

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

ExpressionEngine News!

#eecms, #events, #releases