gpt4 book ai didi

CakePHP - 单选按钮未显示错误消息

转载 作者:行者123 更新时间:2023-12-05 00:06:53 28 4
gpt4 key购买 nike

使用 CakePHP 表单助手创建单选表单时,我无法显示错误消息。

这就是我现在所拥有的。

     $options=array('active'=>'Active','inactive'=>'Inactive');
echo $form->input('Status', array(
'type' => 'radio',
'id' => 'EntryStatus',
'name' => 'data[Entry][status]',
'options' => $options

));

我错过了什么?
我正在使用 CakePHP 1.2.7,这就是我在验证中所拥有的
'status' => array(
'notempty' => array(
'rule' => 'notempty',
'required' => true,
'message' => 'yo'
)
)

尝试了来自 Form helper for creating Radio button in Cakephp 的答案它给了我一个选择选项表。

谢谢,
球座

最佳答案

有同样的问题,我发现了这个,它有效:

http://book.cakephp.org/view/204/Form-Element-Specific-Methods

你需要

if ($form->isFieldError('gender')){
echo $form->error('gender');
}

...在您的代码中。这适用于您的字段被命名为性别的情况。

关于CakePHP - 单选按钮未显示错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2768605/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com