zjffdu
zjffdu

Reputation: 28944

How can I show one record's associated records in another table in CRUD?

Take the tutorial YABE as example, in the CRUD, for Post, it can show its related tags, but it can not show its related comments. So how can I let it show its related comments ?

Thanks.

Upvotes: 2

Views: 175

Answers (1)

emt14
emt14

Reputation: 4896

Limitation

The CRUD module only shows bi-directional relationships in one of the two entities: the one that does not have the mappedBy attribute.

Use the custom tag if you need to.
Something like:

<div id="crudListTable">
    #{crud.table fields:['name','description','comments']}
    #{crud.custom 'description'}
       #{if object.description}${object.description.length() > 50 ? object.description[0..50] + '…' : object.description}#{/if}
    #{/crud.custom}
    #{crud.custom 'comments'}
        #{list items:object.comments, as:'comment'}
            ${comment.description} /
        #{/list}
    #{/crud.custom}
    #{/crud.table}
</div>

Upvotes: 1

Related Questions