Cake PHP总是返回0 $ this-> Layout-> boolYesNo($ inquiry [' Inquiry'] [' read']

时间:2014-05-03 13:25:51

标签: php cakephp

此值$enquiry['Enquiry']['read']返回1,但在视图文件中,状态为no ..i已打印显示的值1 ..

echo $this->Html->link($this->Layout->boolYesNo($enquiry['Enquiry']['read']), array('controller' => 'enquiries', 'action' => 'toggle_status', $enquiry['Enquiry']['id']), array('escape' => false));

1 个答案:

答案 0 :(得分:1)

$answer = ($enquiry['Enquiry']['read'] == 0) ? 'No' : 'Yes';
echo $this->Html->link($anwer, array('controller' => 'enquiries', 'action' => 'toggle_status', $enquiry['Enquiry']['id']), array('escape' => false));

//OR
$current_enquiry = ($enquiry['Enquiry']['read'] == 0) ? false : true;
echo $this->Html->link($this->Layout->boolYesNo($current), array('controller' => 'enquiries', 'action' => 'toggle_status', $enquiry['Enquiry']['id']), array('escape' => false));
// it does say boolYesNo, so my guess is that it's expecting a bool (not int)