I have a feed where one element is to be mapped to a multiselect field on an entry. However, I would need to tweak the values I'm importing (basically making them lowercase), to match the values of my multiselect field in Craft (I would rather map to value than label, although even if I mapped to labels, I would need to do some changes to the imported values).

I've tried more or less every event that FeedMe offers me (and some I've found in the code that are not in the docs), but I cannot find any that seems to do the trick.

I tried to use EVENT_BEFORE_PARSE_FIELD, which seemed to be a logical point (though the event is not mentioned in the docs), but as it doesn't actually set the values changed in the event back to the values passed in (as it does with other events), the changes are simply lost. So no luck.

On my last try, I tried using EVENT_STEP_BEFORE_ELEMENT_SAVE, and changing the $contentData. But, as far as I can see, this variable is not passed in to the actual save function, it's just passed to an aftersave function, that for entries seems to do absolutely nothing.

So, short of having to loop through the entire feed, searching for the attribute in question in every node, and changing each of them, I can't see how to achieve this. It would make sense to be able to tweak the values passed in at some point where the code is handling one node, but I can't seem to find it.

If anyone have any ideas, I would really appreciate it.

1 Answer 1


Have you tried EVENT_AFTER_PARSE_FIELD https://github.com/craftcms/feed-me/issues/516

use yii\base\Event;
use craft\feedme\services\Fields;
use craft\feedme\events\FieldEvent;

Event::on(Fields::class, Fields::EVENT_AFTER_PARSE_FIELD, function(FieldEvent $event) {
    if ($event->fieldHandle === 'myAssetsField' && $event->fieldValue !== null) {
        // $event->fieldValue will be an array of assets (already saved).
        // Modify the assets or the field value as needed...
  • Ah, this would do the trick! It's exactly what I'm missing from the events I've tried, that it actually uses the values changed when returning back to the FeedMe code. Incidently, I just updated from the 4.1.1 to the 4.1.2 version that came two days ago, and the change finally seems to be commited, so I don't need to update to a dev branch. Will do a test and report back!
    – KSP
    Commented Aug 13, 2019 at 9:04
  • Bingo, it worked like a charm. Thank you! Ideally, I think it would make sense to modify imported values even earlier, as I now have to go back to the raw $event->feedData and fetch it again, before doing my modifications, and saving it back to $event->parsedValue. As long as I know the values needs to be modified anyways, it would be nice to do it before FeedMe tries to parse it itself, thus leaving me with an empty $event->parsedValue (presumably because the value failed to validate on the model).
    – KSP
    Commented Aug 13, 2019 at 9:27
  • Great, glad it worked – haven't used it myself but had that bookmarked to use on a project soon.
    – dmatthams
    Commented Aug 13, 2019 at 9:31
  • Then rest assured it works! :) Thanks for your help!
    – KSP
    Commented Aug 14, 2019 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.