1

front end devs, do you put your dropdown values in a database or in the code? follow up question. if database, do you put all the dropdowns in one table?

Comments
  • 5
    It depends of course. Are the values static or dynamic? Localized? How many?
    A dropdown is just a UI control to select one value from a list. When you realize that, you also realize that it depends on the contents of that list.
  • 3
    And there are more options than (hard) code and relational database (tables).
  • 2
    I've seen a few different database centric versions, and am firmly on the side of storing all lookup values in a single table, but also storing the string directly in the database record instead of the reference. It makes all the difference when lookups get updated by idiots and you don't then lose data integrity.

    Hard coding seems wrong for anything which has the potential to change, but is perfectly good for core options essential to functionality
  • 1
    Because of

    - mostly language dependent and

    - mostly many values using an autocomplete UI

    > database

    Also the frontend devs can mostly not know, what the backend will do with the values ...
  • 1
    I like to think of the backend in terms of an API. If I use an API I don't expect to first call the API to get a list of viable options to choose from, I read their docs. So for me I hard code the options in the frontend but if it's multi choice it's usually an enum for me
Add Comment