How to control the fields to display for belongsToMany for pagination in Cake 3.x?
<h1>Situation</h1>

<p>Using <code>Cake 3.2.4</code></p>

<p>I have a <code>EventTicketSales</code> table</p>

<p>that</p>

<pre><code>  $this-&gt;belongsToMany('Approvings', [
        'className' =&gt; 'Contacts',
        'joinTable' =&gt; 'event_ticket_sales_approvings',
        'targetForeignKey' =&gt; 'contact_id',
        'saveStrategy' =&gt; 'replace',
    ]);
</code></pre>

<p>So when I do a pagination in EventTicketSales table, I only want to display 2 fields from the Approvings, i.e. Approvings.name and Approvings.company.</p>

<h1>What I have tried</h1>

<p>I have tried the following:</p>

<pre><code>$this-&gt;paginate["contain"] = ["Approvings"];
$this-&gt;paginate['fields'] = [
            'EventTicketSales.id', 'EventTicketSales.event_id', 'EventTicketSales.billing_amount_in_sgd', 
            'EventTicketSales.payment_terms', 'EventTicketSales.invoice_number', 
            'EventTicketSales.due_date',
  'Approvings.id', 'Approvings.name', 'Approvings.company'
        ];
</code></pre>

<p>I got an error message about JsonSerialize in a non related model.</p>

<pre><code>  [Exception] Failed calling App\Model\Entity\User::jsonSerialize() #0 /var/virtual/WebApps/corri/vendor/cakephp/cakephp/src/View/JsonView.php(0
</code></pre>

<h1>What I expected</h1>

<p>I expected the results in the following: (I am showing in json format)</p>

<pre><code>id: "06f39ba3-9a17-47c6-9374-24b49fb64665",
event_id: 7,
billing_amount_in_sgd: 7680.03,
payment_terms: "45 days",
invoice_number: "9191",
due_date: "2016-03-05T00:00:00+0800",
approvings: [
    {
        id: 63,
        name: "Jaime Jen",

        company: "Apple Company",

        _joinData: {
            contact_id: 63,
            id: 335,
            event_ticket_sale_id: "06f39ba3-9a17-47c6-9374-24b49fb64665",
            created: "2016-01-20T13:43:44+0800",
            modified: "2016-01-20T13:43:44+0800"
        }
    }
]
</code></pre>