开发者

Use $this->Paginator->sort sort by a field not in the related model

开发者 https://www.devze.com 2023-02-09 18:13 出处:网络
I want to use $this->Paginator->sort to generate a link, but sorted by a field not in the current table, which related to this table. So can I do that? and h开发者_C百科ow to do that?

I want to use $this->Paginator->sort to generate a link, but sorted by a field not in the current table, which related to this table. So can I do that? and h开发者_C百科ow to do that?

Thanks so much!


For an external field on sort, you can do so like:

<th><?php echo $this->Paginator->sort('ExternalModelName', 'ExternalModelName.fieldname'); ?></th> 

But the model relationship must also be correct. So assuming your relationship is setup correctly, the above will work.

0

精彩评论

暂无评论...
验证码 换一张
取 消