禁用的表单元素未提交 [英] The disabled form element is not submitted

查看:40
本文介绍了禁用的表单元素未提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从表格中显示一些预先存在的数据,但需要禁用它们以防止用户编辑它们.所以我禁用了它们

I needed to show some preexisting data from a table and but needed to disable them to prevent user from editing them. So i disabled them

$form ->getElement("elementname") ->setAttrib("disable", true);

当我提交表单时,我发现表单元素根本没有被提交,只是因为它被禁用了.我在测试删除禁用选项时确认了这一点.

When I submit the form, I found out, that the form element does not get submitted at all, just because it was disabled. I confirmed this when I tested removing the disable options.

发生了什么?难道我做错了什么?如何解决这个问题?

What is happening? Am i doing something wrong? How to solve this?

推荐答案

这是设计使然,禁用的元素不会随表单一起提交.

This is by design, disabled elements do not get submitted with the form.

您所做的实际上是一种空做法,无论您对该表单做什么,都最终用户可以对其进行编辑.您根本无法相信表单输入 - 甚至隐藏字段 - 不会被篡改.

What you are doing is actually a null practice, no matter what you do to that form in put it will be editable by the end user. You simply cannot trust form input - even hidden fields - to not be tampered with.

最好的办法是向用户显示信息并在提交表单后再次加载它;最坏的情况是将其存储在会话中.

Your best bet is to just display the information to the user and load it again after the form has been submitted; at worst store it in a session.

这篇关于禁用的表单元素未提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆