Editor Ajax URL Replacement not working for uploads

Editor Ajax URL Replacement not working for uploads

rozrorozro Posts: 11Questions: 1Answers: 0
edited November 17 in Editor

Hi, i just noticed that the {id} URL Parameter in Editor is not working for "upload" object.

See example here:
https://live.datatables.net/holeqaca/4/edit

The POST is executed to url: https://live.datatables.net/upload/%7Bid%7D and the {id} is not replaced.

I think this is a bug.
Is it possible to fix it?

Replies

  • allanallan Posts: 65,347Questions: 1Answers: 10,841 Site admin

    Thanks for the test case!

    I'm afraid it actually isn't a bug. The issue is that there might not be a row id - i.e. when creating a row, so it doesn't attempt to do that replacement.

    The way Editor treats files is that they are async from the rest of the form - i.e. they are uploaded immediately when selected. When a row is being created, there is no corresponding host row. Once the upload is complete an id is returned (representing a link to that file - typically a primary key, but it could be something else) and that is the value that the field takes and will be written to the host row when the form is created.

    Allan

  • rozrorozro Posts: 11Questions: 1Answers: 0

    Thank you for quick response!

    I thought about that and actually i'm implementing myself all the checks needed.
    For example i've made 2 custom template to hide uploads on create form and show them only on edit form. Obviously i've made server side checks.
    That's how i discovered this issue.

    I think this should be handled by developer.
    For example one should want to create a datatable item, upload a file which returns an id and that should be saved on the datatable item.

    I also tried replacements which seems to not work either ( or maybe that's my fault? )
    Please check my test case updated

  • allanallan Posts: 65,347Questions: 1Answers: 10,841 Site admin

    The replacements don't run for the file upload I'm afraid. That is something I will look at adding. At the moment you would need to use ajax as a function and make your own Ajax call if you want to do replacements for the file upload Ajax request.

    Allan

  • rozrorozro Posts: 11Questions: 1Answers: 0

    Ok thank you!

Sign In or Register to comment.