Is there a way to allow null values in a join-column with type: select?
Is there a way to allow null values in a join-column with type: select?
HolmbergMa
Posts: 3Questions: 1Answers: 0
in Editor
When setting up a column with a foregin key I want the select dropdown to include a null option in addition to every value in the related table. Is this possible?
I've set up my table on both server side and client side according to this page: https://editor.datatables.net/manual/php/joins
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Editor 1.5.4 has a new
placeholder
option for theselect
field type. That can be used to add an "No item selected" type of option. Also use theplaceholderDisabled
option to allow the end user to select it.I would suggest having the placeholder value as an empty string and then at the server use a set formatter (
ifEmpty
) to write a null into the database when the empty string is found.It might sound a little complicated, but its just a couple of additional lines of code :-)
Allan
Thanks Allan!
I think that this solution will fit my needs perfectly!
However now I think that I have issues with the syntax for the placeholder and placeholderDisabled options.
I tried what I thought was the logical approach to add the options in the field-array which i use in the call when i create the editor instance.
{ label: labelName,
name: fieldName,
type: "select",
placeholderDisabled: false,
placeholder: "placeholderText"}
Is this correct or do I need to create my field first and then use the field().update( options ) to add the placeholder?
I was running an older version of Editor...
With Editor 1.5.4 it now works Perfectly!
Thanks for posting back - good to hear the new version works well for you!
Regards,
Allan