I have a custom Element Type to which I can add several custom fields. I can create a front end form with most of those custom fields and the submitted data saves just fine. However, I'm getting some odd behavior with the Assets field.
I can save Assets fields from the front end of Craft to Craft sections just fine. And I can edit one of the Entries for my custom Element types on the backend and upload an Asset just fine there as well.
But when I submit an Asset from the front-end for a new Entry with this custom Element type, I don't get the right behavior.
What does happen (as far as I can tell):
- The asset uploads and appears in the target upload folder
- A new row in the craft_relations table is created correctly identifying the asset and the element that it is related to.
What doesn't happen:
- The uploaded asset doesn't appear in the Asset index. Even if I reindex assets for this particular folder, it never shows up in the Assets file manager.
- When I visit the individual entry page in the CP, the Asset never appears. (But if I upload the asset directly from this CP page, the asset then does appear on this same page)
I'm struggling to know where to look to troubleshoot this. What would cause an Asset not to display properly when it's uploaded from the front end but to work fine when it's uploaded from the back end? Could I be missing some data on the front end submission? My form uses enctype="multipart/form-data"
and the asset field is as simple as it gets (and I've tried several variations (<input type="file" name="fields[uploadfield]" >
)