保存禁用字段 [英] Saving a Disabled field
问题描述
在我的edit.ctp文件中,有一个选择框,不需要用户更改.所以我放了 array(disabled => true)
.但是什么时候该字段不会出现
In my edit.ctp I have a select box which I don't need the user to change. So I put array(disabled=>true)
. But this field is not coming when
pr($ this-> data);
并在保存时显示错误.
pr($this->data);
and showing an error while saving.
有哪些选项可以解决此问题.
What options are there to solve this issue.
推荐答案
您可以将字段设置为只读,以使用户无法更改它,或使用一些隐藏的字段来发布所需的数据,或者您可以使用某些css,例如 visibility:hidden ,这样用户看不到它,但是它将被发布.
You could make the field readonly so that user cant change it , or use some hidden field to post the data that you want, or you could use some css, like visibility:hidden, so that user dont see it but it'll be posted.
echo this->Form->input('patient_id',array('type'=>'hidden'));
您可以使用其他名称作为输入并检入控制器,也可以从视图中完全删除select元素* 强文本 *(因为用户不需要这样做,因此不需要它)更改它)
You can use some other name for the input and check in controller, or you could completely remove the select element from the view*strong text* (since, its not needed as user dont need to change it)
这篇关于保存禁用字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!