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 Field Error

June 04, 2012 4:56pm

Subscribe [2]
  • #1 / Jun 04, 2012 4:56pm

    Genevieve

    52 posts

    I’ve got a safecracker form on a client’s site that has a safecracker file field for uploading images to a gallery. This field is required. It *was* working at one point, but during testing it stopped working for some reason. Now when a file is added to that field, and the entry is submitted, EE kicks back a “The form you submitted contained the following errors: The Layout Image field is required” message—as if no image was selected, except that there was. Uploads work fine from the CP. So what gives with my safecracker form?

    The code I’m using is below:

    {exp:safecracker channel="my_channel" return="my_channel/URL_TITLE" url_title="{segment_3}"}
    
        <label for="title">Title*</label>
        <input type="text" name="title" id="title" value="{title}" size="50" maxlength="100">
     
     <label for="layout_image">Layout Image*</label> 
     Image must be no larger than 600px x 600px and 200kb in size.
     {field:layout_image} 
    
     <label for="layout_description">Layout Description</label>
            {if field_instructions}{field_instructions}{/if}
     {field:layout_description}
    
    {if member_group == "6" OR member_group == "1"}
    {custom_fields}
     {if relationship}
     <label for="{field_name}">{if required}* {/if}{field_label}</label>
            {if field_instructions}{field_instructions}{/if}
      
                    <select id="{field_name}" name="{field_name}">
                            {options}
                                    <option value="{option_value}"{selected}>{option_name}</option>
                            {/options}
                    </select>
            {/if}
    {/custom_fields}
    {/if}
    
    
        <div id="categorySelect">
            <label for="categories">Categories</label>
            {categories}
          
           <input type="checkbox" name="category[]" id="categories" value="{category_id}" {checked} />
           <span>{category_name}</span>
          
          {/categories}
     <div class="clear"></div>
        </div>
    
        {if captcha}
            <label for="captcha">Please enter the word you see in the image below:</label>
            {captcha}
            <input type="text" name="captcha" value="{captcha_word}" maxlength="20">
        {/if}
     <label class="checkbox"><input type="checkbox" name="allow_comments" value="y" {allow_comments}> Allow Comments</label>
     <input type="hidden" name="status" id="status" value="open"> 
        <button type="submit" name="submit">Submit</button>
    {/exp:safecracker}
  • #2 / Jun 05, 2012 1:14pm

    Dan Decker

    7338 posts

    Hi Genevieve,

    Sorry for the trouble you’ve had with this!

    Have you run an update recently?

    If so, make sure the version of SafeCracker File Fieldtype you are using is the version that is included in the /system/expressionengine/third_party folder of the new download.

    I look forward to your reply!

    Cheers,

  • #3 / Jun 05, 2012 1:25pm

    Genevieve

    52 posts

    Thanks for that, Dan. I did just update to 2.5.1, so I went in and reinstalled the SafeCracker File that came with 2.5.1, but alas—I’m still getting the same error. It’s like it doesn’t recognize that a file has been selected for upload…

  • #4 / Jun 05, 2012 3:48pm

    Genevieve

    52 posts

    I found another thread that describes the same thing I’m experiencing: http://ellislab.com/forums/viewthread/205913/ Unfortunately, it’s an unsolved thread.

    Now that I think about it, the last time I know for sure the form was working was on my local development environment—I’m not sure I tested it successfully after I transferred the site to my client’s hosting. What kinds of hosting issues could get in the way of a safecracker file uploading from a safecracker form? File uploads work fine from the CP.

  • #5 / Jun 05, 2012 4:03pm

    Genevieve

    52 posts

    Okay, I just made the safecracker file field NOT required, and all of a sudden it’s working. But, I need that to be a required field—I don’t want it to submit without a file attached. So it seems like the required field function is working the opposite of how it should for this one particular field. Any ideas why that is, and how I can get it to work as it should?

  • #6 / Jun 06, 2012 7:40pm

    Joobs

    362 posts

    I’m also having the same issue, my dev copy was 2.5 and my live site is 2.5.1. 

    Seems to work on the dev site but not on the live site

  • #7 / Jun 07, 2012 12:28pm

    Genevieve

    52 posts

    Still hoping for an answer to this one. I’ve tried everything I can think of. Anyone?

  • #8 / Jun 07, 2012 1:49pm

    Joobs

    362 posts

    I’ve not tried this yet, but I think safecracker has some kind of validation paramater.  So you could leave the “required” off in the cp, but force it on with the safecracker form.  Might work.

    At the moment I’m using javascript to validate the form

  • #9 / Jun 07, 2012 2:06pm

    Genevieve

    52 posts

    Thanks for that, Joobs. I just gave it a try, but unfortunately it didn’t work. I left “required” off the field in the CP, but used the Safecracker parameters to require the field, and ended up with the same result as when I require the field on the back end—a “This field is required” error popped up, even when a file was submitted to that field. So right now I’m having to leave required off that field entirely, which means entries can be submitted without a file, which I don’t want…

  • #10 / Jun 11, 2012 12:41pm

    Dan Decker

    7338 posts

    Hi Genevieve,

    Sorry for your delay over the weekend!

    We did some work on the SafeCracker File fieldtype with a recent update.

    Before the update, the field would validate when required even if there was no file present due to a bug of sorts. It would seem that we have introduces a new bug along the way. I have confirmed and reported it here.

    Thanks for bringing this to our attention.

    Sorry for your inconvenience!

    Is there anything else I can assist you with?

    Cheers,

  • #11 / Jun 12, 2012 10:22am

    Genevieve

    52 posts

    Thanks for the update, Dan. I have a feeling it’s going to put me in a bit of hot water with my client. Is there any way to be notified when that bug is fixed?

    Other than that, I guess I’m set on this issue.

  • #12 / Jun 13, 2012 4:24pm

    Dan Decker

    7338 posts

    Hi Genevieve,

    You *might* be able to validate on the browser with a bit of clever JavaScript.

    If you comment on the bug report, you will be notified when there is progress.

    If you need anything else, please let us know in a new thread.

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases