Custom button in editor form - Clear all Select/Input values
Custom button in editor form - Clear all Select/Input values
I want to have a 2nd custom button in the create form.
I'm calling editor like this which of course works for one button:
editor
.create( {
title: 'Some Title',
buttons: 'Create Record'
} );
And e.g. I tried this for having a second button in the form:
editor
.create( {
title: 'Some Title',
buttons: [{
extend: 'create'
text: 'Submit your Vote!'
}, {
text: 'Clear Select/Input',
action: function ( e, dt, node, config ) {
// clearing all select/input options
}
}]
} );
The second button should clear all the input/select values user has entered in the form so far. But I'm already struggling to with the button itself.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Got it ... like described here: https://editor.datatables.net/reference/type/button-options
Yet, how would a "Clear all Select/Input values of form" button would work?
So it works if I directly run the below and call each data field name which should be cleared (e.g. data: 'field_name'):
Hi,
I hadn't thought before after the difference in the
fn
andaction
methods for the two different button types from the two different bits of software... I should try and harmonise that - thanks for pointing it out.Regarding your question about setting them all to empty - you could do that, although it would probably be easier to use
field().val()
orval()
.You can get a list of the field names (meaning you can set them all to an empty string in a simple
for
loop) usingdisplayed()
.Allan
Perfect ... thanks a lot!