Create with some defaults
Create with some defaults
greggreggreg
Posts: 42Questions: 19Answers: 2
I am trying to do a create with some editing of the field from the same editor that gets used for a Edit. Should this be possible? Pressing my button results in nothing happening.
buttons: [
{
extend: "create",
text: 'New Entry',
action: function ( e, dt, node, config ) {
editor.field( 'field_one' ).hide();
var randomstring = "abc";
editor.field( 'field_one' ).val(randomstring);
editor.field( 'status' ).val('New');
}
},
Also, is it just me or does code formatting not work sometimes and the code button sometimes trim CR.
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I wouldn't use the code button but triple back ticks in order to use Markdown - see below. If you add "js" or "php" or whatever after the initial back ticks it gets even better.
When you do what you do in your code you are extending "create" but you are also completely overwriting the "action" parameter. Hence your button does nothing.
This button does what a "create" button does plus your stuff:
Better not extend the button but use an "on open", "on initCreate" or other events and manipulate your editor values. Like in here for example which is a very special use case of "dependent" for "create" only.
that was perfect thanks.