unselectedValue does not submit a value
unselectedValue does not submit a value
Link to test case: http://cpctestingserver2.info/
Error messages shown:
Uncaught TypeError: Cannot read property 'loading_dock' of undefined
at datatables.js:2736
at Field.valFromData (datatables.js:21536)
at Field.<anonymous> (datatables.js:20348)
at Function.each (jquery-3.5.1.min.js:2)
at Object.<anonymous> (datatables.js:20341)
at Function.each (jquery-3.5.1.min.js:2)
at Editor._submit (datatables.js:20338)
at datatables.js:18818
at Editor._event (datatables.js:19685)
at send (datatables.js:18812)
Description of problem:
When I click "New" and submit the form without selecting either of the radio buttons, I get the above error. It is very likely I am missing something simple, but I am not sure.
You can see a demo of this issue at the above link.
My JS:
editor = new $.fn.dataTable.Editor( {
ajax: '../php/staff-html.php',
table: '#example',
fields: [ {
label: "First name:",
name: "first_name"
}, {
label: "Last name:",
name: "last_name"
}, {
label: "Position:",
name: "position"
}, {
label: "Office:",
name: "office"
},{
type: 'radio',
label: 'Loading Dock Available?',
name: 'loading_dock',
options: [
{ label: 'Yes', value: '1' },
{ label: 'No', value: '0' }
],
unselectedValue: 0,
fieldInfo : 'Note: If you select YES, you will be required to make sure you can get the freight into your location.'
}
]
} );
I am sure it is something simple, but any help would be appreciated!
This question has an accepted answers - jump to answer
Answers
No - you haven't missed anything. I was me who has! There is an error in the code for the radio buttons not correctly using the
unselectedValue
property. I'll need to release Editor 2.0.5 to address this, but as a quick workaround, there is a little change you can make to your datatables.js file to make it work.Search in the file for:
And replace with:
Thanks for bringing this up!
Regards,
Allan
Thank you Allan!