Question

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:

<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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top