Open "create new entry" with parameters

Open "create new entry" with parameters

marcoxmarcox Posts: 7Questions: 2Answers: 0
edited May 2020 in Free community support

I like to open the a prefilled box "create new entry" when the I call the user interface with certain parameters.
My URL is like: /admin/?field=hello&field2=world

My desired result is this:

In short: I want a way to prefill the columns for a new entry. Any Ideas how to get this?

My Code is actually this:
$('#redirectTable').DataTable({
dom: "Bfrtip",
ajax: '/get-entries/',
rowId: 'id',
columns: [
{data: "id"},
{data: "field1"},
{data: "field2"},
],
select: true,
pageLength: 50,
buttons: [
{extend: "create", editor: redirectTable},
{extend: "edit", editor: redirectTable},
{extend: "remove", editor: redirectTable},
['pageLength']
]
});

How can I build this?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,210Questions: 1Answers: 10,415 Site admin
    Answer ✓

    I'd use a initCreate event handler which calls the field().val() method to set the values you need.

    To check if you need to set values, get the query string from window.location.search. You'll need to parse the search string, but there are loads of resources on SO and similar about how to do that.

    Allan

This discussion has been closed.