1

EE v2.7.3 Matrix v2.5.8

I have a Channel:Form where I need to do a ton of custom styling, so I have manually built the form markup, using exactly what is rendered out by {field:my_matrix_field}.

I am not able to upload a new file or replace an existing file through this method.

I can: Upload files in the control panel Upload files by using {field:my_matrix_field} inside the form Upload files by using my own markup tied to a single, non-matrix file field. Post & updated data in text fields within the matrix field, using my own markup.

I cannot: Upload files using my own markup to a matrix field.

Markup created by {field:my_matrix_field}:

<input type="file" name="cb-video[row_id_22][col_id_7]" class="file-chooser">
<input type="hidden" name="cb-video[row_id_22][col_id_7][existing]" value="logo.jpg|3" class="existing_file">

Markup created by me:

<input type="file" name="cb-video[row_id_22][col_id_7]" class="file-chooser">
<input type="hidden" name="not_cb-video[row_id_22][col_id_7][existing]" value="logo.jpg|3" class="existing_file">

Notice I change the name attr of the hidden field to be prepended with "not_". This mimicks what the Matrix JS does to file fields on edit. The {field:my_matrix_field} version will successfully post the data and my markup will not.

Am I missing an additional hidden field or JS file that should be included? I feel like it should work with the manually created markup, so long as it is identical. It works with the other field types just fine.

Thanks!

2
  • If you're creating the exact same markup, what's the point? Why not style the markup that {field:my_matrix_field} creates? Commented Feb 11, 2014 at 6:12
  • Because I've only included the form fields here. The rest of the markup that comes with a matrix field is table-based and will not style in the manner the client needs. Its working wonderfully on everything but the file field.
    – jefweb
    Commented Feb 11, 2014 at 15:56

1 Answer 1

1

I wrote that part of JS some time ago, but if memory serves, then the "not_" prefix was being applied only when "Delete file" link was clicked. It was done so that the Matrix PHP part would not find the file it was looking for and would delete it then. The reason for this JS manipulation is so that the "delete" action is undoable (simply by removing the "not_" prefix).

So just applying "not" without user choosing to delete the file is not the correct way to do this, as the script assumes the file was deleted by the user.

1
  • Yes, I understand the purpose of "not_". Its a great solution for this interaction. I edited it manually in my markup to imitate your JS, in order to make all the form elements as similar as could be to the matrix version. Given that it's not necessary, I've tried removing it altogether but with the same result.
    – jefweb
    Commented Feb 11, 2014 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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