Allow non-integer key for null value in hid choices
The database module has a get_hids() function that generates a list of 2-element lists representing a list of foreign key values and their human-readable equivalents from the database. These are used to present select lists for post categories, nationalities and the like. Generally the keys are integers. The function has an option to add a "null" option to the list, for use in selects where input is optional. The value associated with that defaulted to the integer -1. This became a problem when I needed to add a select field with string keys (post category ids) and also having a null option, because the null option was coerced from an int to a string like the rest of the data, so always failed validation. This change makes the value for the null option configurable but defaulting to -1.
Please register or sign in to comment