Datatables Editor get post data only

Datatables Editor get post data only

davidjmorindavidjmorin Posts: 101Questions: 31Answers: 0

I would like to have in my form just a checkbox to either send email or not. This data will not be posting to the table. Then in the back i want to have an if statement to see if box is checked. How is the data passed to the php file from the form?

Thoughts:

if($_POST['sendEmail'] == '1'){ //Send email }

This question has an accepted answers - jump to answer

Answers

  • davidjmorindavidjmorin Posts: 101Questions: 31Answers: 0
    edited August 2020

    More useful info.

    $(document).ready(function() {
        editor = new $.fn.dataTable.Editor( {
            "ajaxUrl": "php/gc_users.php",
            "domTable": "#example",
            "fields": [ {
                    "label": "MID:",
                    "name": "MID"
                }, {
                    "label": "First name:",
                    "name": "FIRSTNAME"
                }, {
                    "label": "Last name:",
                    "name": "LASTNAME"
                }, {
                    "label": "Email:",
                    "name": "EMAIL"
                },
    
    //////  Between quotes is what im trying to do.  
    //////This sendEmail does not exist in my DB. 
                {
                                label: "Send Email?:",
                                name: "sendEmail",
                                type: "checkbox",
                                separator: "|",
                                options: [{
                                        label: '',
                                        value: 1
                                }]
                        },
    
    //////////////////////////////// End Example /////////////////
            ]
        } );
    

    I tried using $_GET['sendEmail'] and also $_POST with no luck.

  • davidjmorindavidjmorin Posts: 101Questions: 31Answers: 0

    Response from network (F12)

    data[row_11][rma_submissions][rma_number]: 29384u239tt
    data[row_11][rma_submissions][paid]: Yes
    data[row_11][rma_submissions][paid_date]: Tue, 11 Aug 2020
    data[row_11][rma_submissions][vendor]: Ice Mobility
    data[row_11][rma_submissions][device_man]: Apple
    data[row_11][rma_submissions][device_id]: 6238######
    data[row_11][sendEmail]: 1
    action: edit
    
  • davidjmorindavidjmorin Posts: 101Questions: 31Answers: 0

    I figured it out. I am an idiot lol. $values is key to this lol.

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

    Thanks for posting back.

    For anyone else who finds this thread, using a server-side event gives you access to the values for the row, and you can use the event handler to send an e-mail if required.

    Allan

This discussion has been closed.