<p>Using Craft 2 and amforms, I created a massive form on a client's temporary site while working on the full refresh on a staging server.  While that development's been going on, the live temp site has been collecting form submissions the whole time.  We're preparing to overwrite the live server with staging's db, and the only thing that needs to be conserved from the live temp site is all those form submissions that came in.  Does anybody know a solution on how to do this?  I've purchased Verbb's Feed Me plugin but unfortunately it doesn't include importing to custom element types.</p>

CC BY-SA 3.0
2018-01-02T18:55:01.587Z
If it is a custom element in a custom table why don't you just export the table to an SQL file and import it to the other system together with all necessary relations. It only becomes a little bit tricky if there are many relations to other tables. If that's the case the best way would be to create a custom controller that saves all the values from SQL or csv files. In my experience yii makes it incredibly easy to import content because of the record system even if you have the same entries/sections in the other system with different ids
Robin Schambach
CC BY-SA 3.0
2018-01-02T18:59:27.303Z
I tried the export/import SQL approach a while back, but the ids assigned to submissions clash with ids assigned in other places, causing some submissions to not show up in the submissions list.  It seems the best (ideal) approach would be to export the submissions as csv/json, then import them into the database, letting the submissions be assigned ids on import based on what's already there, like Feed Me works. Problem though is that am-forms submissions are not entries; they are their own element type.
Ryan
CC BY-SA 3.0
2018-01-02T19:05:19.197Z
Then you could extend the existing controller or create a custom one that does exactly the same like the form submission just with the values from a json file and not from the post request. Like I said if there are no relations (to users or other entries) it should be no problem. Take a look at the plugins controller and use its behavior and switch the `craft::$app->request` part with your json file
Robin Schambach
CC BY-SA 3.0
2018-01-02T19:07:30.050Z
Ok, that's a good lead.  I'll be looking into it in the next day or two and will report back.  If you got code and want to post as the answer, would appreciate it, but no worries if not and thanks regardless!
Ryan
CC BY-SA 3.0
2018-01-02T19:10:37.790Z
If no one else provides code I'll do it in about 14h because I'm going to sleep soon. I just wanted to provide an idea how to do it since I've done many data migrations in the last few months from many different sources.
Robin Schambach
CC BY-SA 3.0
2018-01-03T08:18:41.257Z
Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/71112/discussion-between-robin-schambach-and-ryan).
Robin Schambach
<database><migration><plugin-amforms>
amforms: Import form submissions from one site into another
# amforms: Import form submissions from one site into another

(Asked by: username_0 on 2018-01-02)

Using Craft 2 and amforms, I created a massive form on a client's temporary site while working on the full refresh on a staging server. While that development's been going on, the live temp site has been collecting form submissions the whole time. We're preparing to overwrite the live server with staging's db, and the only thing that needs to be conserved from the live temp site is all those form submissions that came in. Does anybody know a solution on how to do this? I've purchased Verbb's Feed Me plugin but unfortunately it doesn't include importing to custom element types.

**Tags:** database, migration, plugin-amforms

> **Comments:**
> **username_1**: If it is a custom element in a custom table why don't you just export the table to an SQL file and import it to the other system together with all necessary relations. It only becomes a little bit tricky if there are many relations to other tables. If that's the case the best way would be to create a custom controller that saves all the values from SQL or csv files. In my experience yii makes it incredibly easy to import content because of the record system even if you have the same entries/sections in the other system with different ids  
> **username_0**: I tried the export/import SQL approach a while back, but the ids assigned to submissions clash with ids assigned in other places, causing some submissions to not show up in the submissions list.  It seems the best (ideal) approach would be to export the submissions as csv/json, then import them into the database, letting the submissions be assigned ids on import based on what's already there, like Feed Me works. Problem though is that am-forms submissions are not entries; they are their own element type.  
> **username_1**: Then you could extend the existing controller or create a custom one that does exactly the same like the form submission just with the values from a json file and not from the post request. Like I said if there are no relations (to users or other entries) it should be no problem. Take a look at the plugins controller and use its behavior and switch the `craft::$app->request` part with your json file  
> **username_0**: Ok, that's a good lead.  I'll be looking into it in the next day or two and will report back.  If you got code and want to post as the answer, would appreciate it, but no worries if not and thanks regardless!  
> **username_1**: If no one else provides code I'll do it in about 14h because I'm going to sleep soon. I just wanted to provide an idea how to do it since I've done many data migrations in the last few months from many different sources.  
> **username_1**: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/71112/discussion-between-robin-schambach-and-ryan).  

---

## 0 answers

