Editor Select2 -- Set Default Option Value
Editor Select2 -- Set Default Option Value
mccwebdev
Posts: 20Questions: 6Answers: 2
I'm using Datatable's Editor and have an instance that loads with fields using the Select2 plugin. It's loading a json encoded array.
$document_size = json_encode(['1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8']);
fields: [
{ label: 'Document Type',
name: 'document_type_id',
type: 'select2',
options: <?php echo $document_types; ?>
},
{ label: 'Max Size (MB)',
name: 'max_document_size',
type: 'select2',
options: <?php echo $document_size; ?>
},
{ label: 'Required',
name: 'required',
type: 'select2',
options: [
{ label: "Yes", value: 'Y' },
{ label: "No", value: 'N' }
]
},
{ label: 'Display Order', name: 'display_order' },
],
Is there a way to set the default option in DT editor for a particular field? I'd like to set the max_document_size to default to 4.
Thanks
This discussion has been closed.
Replies
The
field.def
option can be used to set a default value.Allan
That rocks! Thanks so much, been trying many different options and this is simple, clean and easy.