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.

Using SafeCracker File in Matrix - Doesnt upload

September 24, 2012 9:08am

Subscribe [12]
  • #1 / Sep 24, 2012 9:08am

    Ralph123

    26 posts

    Hi Guys,
    trying to narrow down the issue of:
    SafeCracker File 2.1 not uploading files via Matrix 2.4.3 on the front end. Using EE 2.5.3
    Standalone SafeCracker File 2.1 uploads fine, but integrated in Matrix it just doesn’t upload the file to the folder.

    Any ideas? Server issue maybe. In the back end it uploads via matrix fine but not frontend
    Thanks

  • #2 / Sep 25, 2012 9:53am

    Dan Decker

    7338 posts

    Hi Ralph123,

    SafeCracker, Matrix and SC File can be a delicate little butterfly…

    How are you calling the Matrix? Can I see your template code?

    If I recall, you can’t just “call the field” as it were. You have to use the Matrix in a tag pair, then output each column/field independently.

    Let’s get a look at that code and I’ll sort this out with you.

    Cheers,

  • #3 / Sep 28, 2012 8:34pm

    Will Dieterle

    56 posts

    Hi All,

    I’m having the same trouble

    EE 2.5.3
    Matrix 2.4.3

    In my case, the matrix field is being called with the {field:matrix_field_name} syntax inside the safecracker loop.  The Matrix Field has two columns, one text and one Safecracker File (I’ve also tested with just the Safecracker File field present).  From everything that I can discern, the presence of the Safecracker File field in the matrix breaks some part of the form processor, because when that field type is present in the SAEF, even if no file has been attached, no data from the matrix field will be inserted/updated in the exp_matrix_data table and no files are uploaded.

    Everything works as expected, by the way, when using Edit Entry from the Control Panel.  It’s only in the Safecracker powered SAEF that it doesn’t work.

    Anyway, not sure if this is an EE issue or a Matrix issue, I couldn’t find anything about it on Brandon’s site and this Thread seemed encouraging.

    Thanks all!

    Will

  • #4 / Sep 29, 2012 7:07am

    atelier2

    181 posts

    Maybe your issue is related to something I discovered recently?
    Description here: https://getsatisfaction.com/pixelandtonic/topics/my_problem_with_date_fields_in_matrix_and_safecracker?

    I had a complex form and build a long table. sF code was inside that table. Matrix failed to upload content.
    Solution was to Split the table with the form into two halves, and leave SF code outside the table code. Odd but true.

    This does not work with Matrix

    <table border="0" cellspacing="0" cellpadding="0">
    //table rows and columns and other code
    {exp:safecracker channel="channel-B" return="Template_group/Template/ENTRY_ID" entry_id="{segment_4}" }
    //some form fields
    //some more table rows and columns
    //MyMatrixField
    //some more table rows and columns
    Submit
    </table>
    {/exp:safecracker}

    This does work:

    <table border="0" cellspacing="0" cellpadding="0">
    //table rows and columns and other code
    </table>
    {exp:safecracker channel="channel-B" return="Template_group/Template/ENTRY_ID" entry_id="{segment_4}" }
    <table border="0" cellspacing="0" cellpadding="0">
    //some form fields
    //some more table rows and columns
    //MyMatrixField
    //some more table rows and columns
    Submit
    </table>
    {/exp:safecracker}

     

  • #5 / Sep 30, 2012 12:08pm

    Will Dieterle

    56 posts

    Thanks for your suggestion, Atelier2.  In my case the issue is independent of the markup around the from (in other words, when tested even with a blank html page, the form processor still does not handle any content from Matrix when there is a Safecracker File field in Matrix.

    One other factor which stands to mention in my case, these forms are being processed over https and the Safecracker tag is being given the parameters secure_action=“yes” and secure_return=“yes”.  Not sure that that’s at any fault in this, but worth noting.

  • #6 / Oct 01, 2012 3:32pm

    Dan Decker

    7338 posts

    Hey Will,

    I think we should have a look at this. SafeCracker File should work just fine in a Matrix. Be on the lookout for an email from EllisLab and we’ll sort this out!

    Cheers,

  • #7 / Oct 01, 2012 4:02pm

    Will Dieterle

    56 posts

    Thanks, Dan.  I ended up grabbing Assets to do the file management instead of Safecracker File and all is resolved.  If you want to dig into it I can try to duplicate the issue on my dev server, but it sounds to me like this may be an install-specific problem and not an overarching one.

    Will

  • #8 / Oct 02, 2012 11:12am

    Dan Decker

    7338 posts

    Hey Will,

    Thanks for following up!

    If you need anything at all, please let me know. I’ll be happy to dive in at any time!

    Cheers,

  • #9 / Oct 04, 2012 12:37pm

    Ralph123

    26 posts

    Also noticed that when using safecracker in EE (EE2.5.2 with Matrix2.4.3 and Safecracker 2.1) that when hitting submit on an inline validated form that the matrix rows drop all safecracker files but one i.e if u have 3 rows populated with safecracker file filepaths the submit function drops rows 2 and 3.

  • #10 / Oct 05, 2012 3:10pm

    Dan Decker

    7338 posts

    Hi Ralph123,

    I’d like to get a look at this. Be on the lookout for an email from EllisLab!

    ~

  • #11 / Oct 19, 2012 7:11pm

    Hi, wondering if there is any resolution to this issue. We are having the same problem:

    EE 2.5.3
    Matrix 2.4.3
    Safecracker 2.1

    EDIT- to expand on it a bit… Using Safecracker Fieldtype within Matrix in a safecracker form. All other fields (including another safecracker field outside of matrix) work fine. I notice when clicking on Choose a file button inside Matrix, the filename does not appear after chosen. Currently am using {field:field_name} to call the matrix field.

    Dan suggested earlier in the thread not using that method and using the matrix tag pair instead. I tried this:
    {field_name}
    {cell_1}{cell_2}...
    {/field_name}

    But that didn’t seem to work either. Would just output the contents of the matrix field, so not editable. I tried doing this instead:
    {field_name}
    {field:cell_1}{field:cell_2}...
    {/field_name}

    Which also did not work. Any tips Dan?

  • #12 / Oct 23, 2012 11:19am

    Dan Decker

    7338 posts

    Hi Rocket Science!

    Dan suggested earlier in the thread not using that method and using the matrix tag pair instead. I tried this:
    {field_name}
    {cell_1}{cell_2}...
    {/field_name}

    But that didn’t seem to work either. Would just output the contents of the matrix field, so not editable.

    In order for it to be editable, you have to code in the HTML form element you need for the cell:

    {field_name}
    <input type="text" name="{matrix_cell_id}" value="{cell_1}"> 
    <input type="text" name="{matrix_cell_id}" value="{cell_2}">
    {/field_name}

    To get the Matrix cell ID, you have to look at the source in the Control Panel and see how Matrix is referencing that.

    Cheers,

  • #13 / Oct 23, 2012 2:47pm

    Hi Dan,

    Thanks for the advice. Still having some issues though. For one, if I do not have content already added to Matrix via the CP, the tag pair you listed does not show anything.

    Also, so I understand. It seems like using that method, I’d have to recreate everything Matrix normally does within Safecracker (e.g. the entire table, add row button, and hidden fields used). Is that the case?

    Thanks again for your help, much appreciated!

  • #14 / Oct 24, 2012 12:53pm

    Dan Decker

    7338 posts

    Also, so I understand. It seems like using that method, I’d have to recreate everything Matrix normally does within Safecracker (e.g. the entire table, add row button, and hidden fields used). Is that the case?

    With Matrix and SafeCracker, the 2 options are, let Matrix do the work, where it mimics the look in the Control Panel, or hand code it for a custom look.

    Are you using the SafeCracker file field type in your Matrix? What browser are you using when you see the file name disappear?

    Cheers,

  • #15 / Oct 24, 2012 7:59pm

    Thanks Dan,

    I suppose if recreating everything is necessary that shouldn’t be too hard. I would like to get it to just work, however.

    I see the issue in both firefox16 and chrome23. I was however incorrect in saying that the chosen filename does not appear, that does look to function normally.

    The basic issue here is that safecracker file fieldtype doesn’t seem to work within Matrix. Here is a copy of my form_test template:

    {exp:safecracker 
                channel="members" 
                safecracker_head="yes" 
                include_jquery="yes" 
                datepicker="no" 
                entry_id="595"
                require_entry="yes"
                json="no"
                id="test"
                return="member-admin/form_test"
                status="closed"
         logged_out_member_id="1"}
    
    
          <fieldset>
           <label for="Company">Company <em class="required"></em></label>
           <span><input id="title" class="required" name="title" type="text" value="{title}"></span>
          </fieldset>
    
          <fieldset>
           <label for="Description">Company Description <em class="required"></em></label>
           <span><textarea id="member_description" name="member_description" cols="40" rows="10" type="text">{member_description}</textarea></span>
          </fieldset>
    
          <fieldset>
           <label for="file_attachment">Upload File</label>
                                    {field:file_attachment}
          </fieldset>
    
          {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}
          
    
          <fieldset>
           <input value="Submit" id="joinFormSubmit" type="submit">
          </fieldset>
          <div>
           <input type="text" name="status" value="closed" />
          </div>
    
     {/exp:safecracker}

    For some reason all other fields, title, description, etc update when submit is clicked, but any rows added to safecracker do not stick.

    As a test, I added a few more fields as safecracker file field type and added them to the form. I called them file_attachment_1, file_attachment_2, file_attachment_3, etc. I observed the same behavior as using matrix. When I changed the field names to something different, like file_add, adding_files, another_file_field, etc - everything worked fine.

    Very odd.

    At any rate, thanks again for all your help. Appreciate it.

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

ExpressionEngine News!

#eecms, #events, #releases