This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

chris10207
chris10207

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 ?

groar
groar

Although, this is an old topic. I have the same problem. Is there any solution?

chris10207
chris10207

so far, i didnt find any, sorry

alxy
alxy

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

groar
groar

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

chris10207
chris10207

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

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.