This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi, My setup is as following, i have 4 tables: companies, licenses, grades and companies_licenses for the pivot table. companies_licenses table is referencing a column grade_id from the grades table When i try to display the grade value in the column definition for the list like this :
 pivot[grades][grade]:
        label: Financial grade
the grade column does not show up but a json string instead does like :
{"id":3,"license_id":3,"grade":"A1"}
And obviously i want to display the grade column value. Note: same is happening in the CRM plugin with the owner of the opportunity
Any ideas why please ?
Use a partial rather than a simple text column. The text column treets the content as text, thus display the object/record in json serialized form. Partials allow to access these values: http://octobercms.com/docs/backend/lists#column-partial
alxy said:
Use a partial rather than a simple text column. The text column treets the content as text, thus display the object/record in json serialized form. Partials allow to access these values: http://octobercms.com/docs/backend/lists#column-partial
And how could apply this in upper example? What do i need to write in partial file?
Last updated
ok i got it, in the partial you can access the model like this:
<?php
    $bookmarks = null;
    if ($record->bookmarks)
        $bookmarks = $record->bookmarks;
?>
<?php if ($bookmarks): ?>
    <table class="table data">
        <tbody>
        <?php foreach ($bookmarks as $bookmark): ?>
         <tr>
            <td>
                        <?= $bookmark->name ?>
           </td>
       </tr>
        <?php endforeach ?>
        </tbody>
    </table>
<?php endif ?>
                            Last updated
1-6 of 6