<p>Solved it for now by making the file input hidden first and only changing its type attribute to file (using jquery) once the asset get’s deleted, ajax-style.</p>

CC BY-SA 3.0
2017-05-25T20:04:49.997Z
I have a similar set up. Users can publish entries that contain an asset field which is set to "required". They should also be able to edit these entries. In my edit form, I have a hidden field for the asset: `<input type="hidden" name="fields[imageFile]" value="">` I'm not sure what, if anything, to put as the value. The form is not saving because required field not filled in. Is JavaScript (jQuery, other) the only way? If so, would you be willing to share your solution in more detail? Is there another, non JS, solution?
Andrea DeMers
CC BY-SA 3.0
2017-05-25T21:22:14.003Z
It looks like I got it working with hidden field as follows:

`<input type="hidden" name="fields[imageFile][]" value="{{ image.id }}">`
Andrea DeMers
CC BY-SA 3.0
2017-05-29T07:32:16.340Z
Hi Andrea. It was national holiday here in Germany so I only now had time to look into it. You got it working?
Marcus Scheller
CC BY-SA 3.0
2017-12-20T19:22:23.210Z
Hi Marcus, after some time away from this project, I've come back to it  to discover that my solution above does not work after all. Would it still be possible to share your JS solution? Thanks!
Andrea DeMers
CC BY-SA 3.0
2014-10-23T06:53:02.340Z
2014-10-23T06:53:02.340Z
Marcus Scheller
<p>Since file inputs are not allowd to be pre-populated, how do i tell craft that a required asset field is already filled in the front end edit form? Can’t seem to figure this one out.</p>

<p>Edit:
Users can create entries from the front end. Those entries have at least one required field which is an asset (image). Creating an entry works fine. However, when editing an entry the user should be able to change the asset as well so we give them the file input too when editing the entry. If they choose to leave that alone the entry couldn’t get saved since the file input stays empty but is still required.</p>

CC BY-SA 3.0
2014-10-22T17:56:14.350Z
Can you post more detail? Not really clear what you’re trying to do here.
Brandon Kelly
CC BY-SA 3.0
2014-10-22T21:39:34.870Z
Users can create entries from the front end. Those entries have at least one required field which is an asset (image). Creating an entry works fine. However, when editing an entry the user should be able to change the cover as well so we give them the file input too when editing the entry. If they choose to leave that alone the entry couldn’t get saved since the file input stays empty but is still required.

Solved it for now by making the file input `hidden` first and only changing its type attribute to `file` (using jquery) once the cover get’s deleted, ajax-style.

Makes sense?
Marcus Scheller
CC BY-SA 3.0
2014-10-22T21:42:33.383Z
Yes the JavaScript solution is going to be your best bet here. You should post that as an official answer to the question ;)
Brandon Kelly
CC BY-SA 3.0
2014-10-22T21:44:53.100Z
Cool. Will do :)
Marcus Scheller
<assets><form><field><required>
Front end edit required asset
# Front end edit required asset

(Asked by: username_0 on 2014-10-21)

Since file inputs are not allowd to be pre-populated, how do i tell craft that a required asset field is already filled in the front end edit form? Can’t seem to figure this one out.

Edit:
Users can create entries from the front end. Those entries have at least one required field which is an asset (image). Creating an entry works fine. However, when editing an entry the user should be able to change the asset as well so we give them the file input too when editing the entry. If they choose to leave that alone the entry couldn’t get saved since the file input stays empty but is still required.

**Tags:** assets, form, field, required

> **Comments:**
> **username_1**: Can you post more detail? Not really clear what you’re trying to do here.  
> **username_0**: Users can create entries from the front end. Those entries have at least one required field which is an asset (image). Creating an entry works fine. However, when editing an entry the user should be able to change the cover as well so we give them the file input too when editing the entry. If they choose to leave that alone the entry couldn’t get saved since the file input stays empty but is still required.  Solved it for now by making the file input `hidden` first and only changing its type attribute to `file` (using jquery) once the cover get’s deleted, ajax-style.  Makes sense?  
> **username_1**: Yes the JavaScript solution is going to be your best bet here. You should post that as an official answer to the question ;)  
> **username_0**: Cool. Will do :)  

---

## 1 answers

### Answer by username_0 on 2014-10-23. Score: 1 | Accepted answer

Solved it for now by making the file input hidden first and only changing its type attribute to file (using jquery) once the asset get’s deleted, ajax-style.

> **Comments:**
> **username_2**: I have a similar set up. Users can publish entries that contain an asset field which is set to "required". They should also be able to edit these entries. In my edit form, I have a hidden field for the asset: `<input type="hidden" name="fields[imageFile]" value="">` I'm not sure what, if anything, to put as the value. The form is not saving because required field not filled in. Is JavaScript (jQuery, other) the only way? If so, would you be willing to share your solution in more detail? Is there another, non JS, solution?  
> **username_2**: It looks like I got it working with hidden field as follows:  `<input type="hidden" name="fields[imageFile][]" value="{{ image.id }}">`  
> **username_0**: Hi Andrea. It was national holiday here in Germany so I only now had time to look into it. You got it working?  
> **username_2**: Hi Marcus, after some time away from this project, I've come back to it  to discover that my solution above does not work after all. Would it still be possible to share your JS solution? Thanks!  

---

