In a framework like Django or Pylons you can set up function to handle form submissions. If your form involves a dropdown menu (i.e. a select tag) populated with objects from a database you can set the values equal to the primary key for the record like:
在像Django或Pylons这样的框架中,您可以设置函数来处理表单提交。如果您的表单涉及使用数据库中的对象填充的下拉菜单(即选择标记),则可以将值设置为等于记录的主键,如:
<select>
<option value="1">Volvo</option>
<option value="2">Saab</option>
<option value="3">Mercedes</option>
<option value="4">Audi</option>
</select>
Is this a safe practice? Is there anything wrong with using a primary key? If you were not to use the primary key for the value how else can you make this form?
这是安全的做法吗?使用主键有什么问题吗?如果您不使用主键作为值,您还可以制作此表单吗?
1 个解决方案
#1
Using the primary key is fine. What exactly are you concerned with? This is an implementation detail that won't show up to the user in the actual rendered page.
使用主键很好。你究竟在关注什么?这是一个实现细节,不会在实际呈现的页面中显示给用户。
#1
Using the primary key is fine. What exactly are you concerned with? This is an implementation detail that won't show up to the user in the actual rendered page.
使用主键很好。你究竟在关注什么?这是一个实现细节,不会在实际呈现的页面中显示给用户。