So, I am looking for a way to save file revisions from a template. By using the default code on the channel form examples, I can save a new file. However, the example code for saving a revision does not work. It gives me an error:
The form you submitted contained the following errors
field_id_71: This field is required
where field 71 is the file field. However, I have even included that field in the form and I still get the same error.
Here is the test code I am using (without the field_id_71 in it):
{exp:channel:form channel="master_plan_channel" url_title="master-plan-2016" return="{segment_1}/{segment_2}"}
<input type="hidden" name="title" value="{title}">
<input type="hidden" name="url_title" value="{url_title}">
<input type="hidden" name="master_plan_files_directory" value="7" />
<input type="hidden" name="master_plan_files_hidden_file" value="{master_plan_files}{file_name}{/master_plan_files}" />
<input type="file" name="master_plan_files" />
<button type="submit" class="btn btn-primary btn-success">Submit</button>
{/exp:channel:form}
So, am I missing something or is this feature still broken? Is it a bug?
Steve
James, thanks for replying.
For the feature I am trying to access, I am trying to save revisions to a file from a template. I have enabled versioning on the file field and in the CP, I can go to the channel entry and update the file field to a new version of the file and it saves the revision in the same entry. I am trying to accomplish this from the front end for my users.
Here are the links to the documentation for what I am trying to accomplish -
Entry form using manually constructed file field (the second example)
and
Manually constructed input fields (the File field)
In the second link, it says “If editing entries, you will need to specify the existing directory and file name or the file content will be lost”. I assume from this that it is possible to edit the file entry and was hoping that it meant I could save revisions to a file there. Maybe what I am trying is not possible but it would be great if it was. If not, I will have to go with a grid field which would make every file revision in to a separate entry in the grid, but I had issues with grid fields in EE3.0 and haven’t revisited it since to see if I could get it working properly.
Did that clarify what I am trying to accomplish?
Thanks!
Ok. We really only need access to the last uploaded file anyway. But I can’t edit the entry (whether that be to upload a new file or add a revision) at all. So, is it possible to edit the entry from the template (ie, change the content of the entry and file name) from the front end? Can you give me some sample code that would allow me to do that? I tried by copying the code from the links above and entering the correct field names but that is when I get the error that was originally mentioned. If I can get that working, that will be enough for us.
Hi,
It does appear there are some file field bugs in Channel Form in 3.x, related to saving the uploaded files and editing a channel form.
If you remove the file field, are you able to edit the channel form as expected? If so, I would say it’s a bug with the file field in Channel Form, and not one that has been reported yet. If you find this to be the case, please report the bug in our tracker (https://support.ellislab.com/bugs) so it can be triaged, and potentially fixed.
Thanks!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.