How to create select option with null value
How to create select option with null value
I have a scenario where the user can update a record field with a select list.
{
label: "Course Ownership: Sets Own Targets", name: "FridayPlanning.CourseOwnershipSetsOwnTargets",
type: "select", options: yesNoNullOptions
},
where:
var yesNoNullOptions = [{ label: "Blank", value: null }, { label: "No", value: "No" }, { label: "Yes", value: "Yes" }];
If the underlying value is "yes" or "no" the select list saves the correct value. Where I am having difficulty is if I select the "Blank" option. When blank is selected, I need the database value to be null instead of an empty string.
I just wanted to confirm that I'm not missing something obvious. Is it possible to save a value as null instead of as an empty string?
This question has an accepted answers - jump to answer
Answers
https://editor.datatables.net/manual/php/formatters#Empty-values
nullEmpty
To elaborate on @tangerine's answer, in this scenario the "set formatter" is applied in the MVC Controller Action and not in the View.