<p>This gives you an <a href="https://craftcms.com/docs/templating/entrymodel" rel="nofollow">EntryModel</a>:</p>

<pre><code>$entryModel = $event-&gt;params['entry'];
</code></pre>

<p>This will give you an array of <a href="https://craftcms.com/docs/templating/assetfilemodel" rel="nofollow">AssetFileModels</a>:</p>

<pre><code>$assetFileModels = $entryModel-&gt;myAssetFieldHandle
</code></pre>

<p>You can loop through them like so:</p>

<pre><code>foreach ($assetFileModels as $assetFileModel)
{
    $url = $assetFileModel-&gt;getUrl();
}
</code></pre>

CC BY-SA 3.0
2016-06-07T17:06:28.173Z
2016-06-07T17:06:28.173Z
Brad Bell
<p>What about <code>$event-&gt;params['entry']-&gt;{fieldname}</code></p>

<p>Wouldn't that be enough?</p>

CC BY-SA 3.0
2016-06-07T14:45:55.680Z
2016-06-07T14:45:55.680Z
Tom De Smet
<p>I'm listening on an entries save event with:</p>

<pre><code>craft()-&gt;on('entries.saveEntry', function(Event $event) {
  //$event-&gt;params['entry']); -&gt; passes to function 
});
</code></pre>

<p>How can I assess assets that are also part of that saved entry?</p>

<p><code>$event-&gt;params['entry']-&gt;getContent()-&gt;{fieldname}</code> doesn't give me the array with information I was hoping for.</p>

<plugin-development><assets><events>
How do I access an asset field in the 'onSaveEntry' event?
# How do I access an asset field in the 'onSaveEntry' event?

(Asked by: username_0 on 2016-06-07)

I'm listening on an entries save event with:
craft()->on('entries.saveEntry', function(Event $event) {
  //$event->params['entry']); -> passes to function 
});

How can I assess assets that are also part of that saved entry?
$event->params['entry']->getContent()->{fieldname} doesn't give me the array with information I was hoping for.

**Tags:** plugin-development, assets, events

---

## 2 answers

### Answer by username_1 on 2016-06-07. Score: 1 | Accepted answer

This gives you an EntryModel:
$entryModel = $event->params['entry'];

This will give you an array of AssetFileModels:
$assetFileModels = $entryModel->myAssetFieldHandle

You can loop through them like so:
foreach ($assetFileModels as $assetFileModel)
{
    $url = $assetFileModel->getUrl();
}


---

### Answer by username_2 on 2016-06-07. Score: -1

What about `$event->params['entry']->{fieldname}`

Wouldn't that be enough?


---

