<p>I have an entry form that includes an asset field called <code>photoHalfBlock</code>. The asset field has its own custom field called <code>photoType</code>. Can I set a custom field on the asset as part of my entry form? Currently, I'm saving the asset to the entry form, then going into the admin to find the asset, manually setting the custom field, saving  the asset, and then going back to the front-end to continue the user flow.</p>
<p>Closest thing I've found is in the Craft docs for setting the asset's filename with a hidden input:</p>
<pre><code>{{ hiddenInput(
  'fields[myFieldHandle][data][]',
  'data:image/jpeg;base64,my-base64-data'
) }}
{{ hiddenInput('fields[myFieldHandle][filename][]', 'myFile.ext') }}
</code></pre>
<p>I did a test by using the filename input like this, but it throws an error, maybe since I'm not using the base64 approach in the file input:</p>
<pre><code>&lt;input id=&quot;photoUploadButton&quot; type=&quot;file&quot; name=&quot;fields[photoHalfBlock][]&quot; value=&quot;&quot; multiple&gt;
{{ hiddenInput('fields[photoHalfBlock][filename][]', 'myFile.png') }}
</code></pre>
<p>What I'm after is something like this where the custom field is <code>photoType</code> and the value I want to set is <code>halfBlock</code>.</p>
<pre><code>&lt;input id=&quot;photoUploadButton&quot; type=&quot;file&quot; name=&quot;fields[photoHalfBlock][]&quot; value=&quot;&quot; multiple&gt;
{{ hiddenInput('fields[photoHalfBlock][photoType][]', 'halfBlock') }}
</code></pre>
<p>I found 1 similar question from a while back but nobody responded to it :(. So I'm hoping for more luck with this one.</p>

CC BY-SA 4.0
2021-11-25T14:05:49.070Z
Sorry, a question, so you mean inside your entry there will be another photoType field, then when you save an entry the photoType field will be automatically updated? Btw inside your entry you can also updating the asset by double clicking the asset thumbnail.
aodihis
CC BY-SA 4.0
2021-11-25T18:26:17.853Z
Yeah, I think so. I think the trouble is that the `photoType` field is relative to the asset field, not the main entry. But I'm assuming you can do that if you're also able to set the file name for the asset.
Michael Todd
CC BY-SA 4.0
2021-11-25T18:27:37.057Z
Thanks for the tip on double-clicking the asset thumbnail in the admin. That helps for the mean time until I get this working from the front-end entry form.
Michael Todd
<assets><entry><assets-field><entry-form>
How to save custom field for asset field in entry form
# How to save custom field for asset field in entry form

(Asked by: username_0 on 2021-11-25)

I have an entry form that includes an asset field called photoHalfBlock. The asset field has its own custom field called photoType. Can I set a custom field on the asset as part of my entry form? Currently, I'm saving the asset to the entry form, then going into the admin to find the asset, manually setting the custom field, saving  the asset, and then going back to the front-end to continue the user flow.
Closest thing I've found is in the Craft docs for setting the asset's filename with a hidden input:
{{ hiddenInput(
  'fields[myFieldHandle][data][]',
  'data:image/jpeg;base64,my-base64-data'
) }}
{{ hiddenInput('fields[myFieldHandle][filename][]', 'myFile.ext') }}

I did a test by using the filename input like this, but it throws an error, maybe since I'm not using the base64 approach in the file input:

{{ hiddenInput('fields[photoHalfBlock][filename][]', 'myFile.png') }}

What I'm after is something like this where the custom field is photoType and the value I want to set is halfBlock.

{{ hiddenInput('fields[photoHalfBlock][photoType][]', 'halfBlock') }}

I found 1 similar question from a while back but nobody responded to it :(. So I'm hoping for more luck with this one.

**Tags:** assets, entry, assets-field, entry-form
> **Comments:**
> **username_1**: Sorry, a question, so you mean inside your entry there will be another photoType field, then when you save an entry the photoType field will be automatically updated? Btw inside your entry you can also updating the asset by double clicking the asset thumbnail.  
> **username_0**: Yeah, I think so. I think the trouble is that the `photoType` field is relative to the asset field, not the main entry. But I'm assuming you can do that if you're also able to set the file name for the asset.  
> **username_0**: Thanks for the tip on double-clicking the asset thumbnail in the admin. That helps for the mean time until I get this working from the front-end entry form.  

---

## 0 answers

