Silverstripe 3.2: How to make a custom action button in the CMS to create a new Dataobject and populate it from another one
<p>I'm searching for a way to create a custom action button which allows me to make a new DataObject with pre-filled content from another DataObject. As a simple example: When I have an email and click the "answer"-button in my email-client, I get a new window with pre-filled content from the email before. I need exactly this functionality for my button. This button should appear next to each DataObject in the GridField.</p>

<p>So I know how to make a button and add it to my GridField (--> <a href="https://docs.silverstripe.org/en/3.2/developer_guides/forms/how_tos/create_a_gridfield_actionprovider/" rel="nofollow">https://docs.silverstripe.org/en/3.2/developer_guides/forms/how_tos/create_a_gridfield_actionprovider/</a>) and I know how to go to a new DataObject:</p>

<pre><code>Controller::curr()-&gt;redirect($gridField-&gt;Link('item/new'));
</code></pre>

<p>I also found out that there is a duplicate function for DataObjects:</p>

<pre><code>public function duplicate($doWrite = true) {
        $className = $this-&gt;class;
        $clone = new $className( $this-&gt;toMap(), false, $this-&gt;model );
        $clone-&gt;ID = 0;

        $clone-&gt;invokeWithExtensions('onBeforeDuplicate', $this, $doWrite);
        if($doWrite) {
            $clone-&gt;write();
            $this-&gt;duplicateManyManyRelations($this, $clone);
        }
        $clone-&gt;invokeWithExtensions('onAfterDuplicate', $this, $doWrite);

        return $clone;
    }
</code></pre>

<p>Perhaps it's easier than I think but at the moment I just don't get how to rewrite this to get what I need. Can somebody give me a hint?  </p>