Popup Selection Ajax NEW

On Button ajax call, define form to pick parameters. Click to publish and view a popup window.

HIDE CODE
<?php

// Get an instance of Xcrud
$xcrud = Xcrud::get_instance();

// Set the table to 'base_fields'
$xcrud->table('base_fields');

// Define columns to display: 'text', 'date', 'bool'
$xcrud->columns('text,date,bool');

// Create custom actions 'publish' and 'unpublish', which are defined in functions.php
$xcrud->create_action('publish', 'publish_action');
$xcrud->create_action('unpublish', 'unpublish_action');

// Define a button 'unpublished' with specific attributes and conditions
$xcrud->button(
    '#', 
    'unpublished', 
    'icon-close glyphicon glyphicon-remove', 
    'xcrud-action', 
    array(
        // Set data attributes for the button
        'data-task' => 'action',
        'data-action' => 'publish',
        'data-primary' => '{id}'
    ),
    array(
        // Set condition when the button should be shown (when 'bool' column is not equal to '1')
        'bool',
        '!=',
        '1'
    )
);

// Prepare a JSON string representing a form definition
$form = urlencode('[{"title":"Status","id":"status", "type":"select","options":"<option value=1>Done</option><option value=2>Non Done</option>"},{"title":"Description","id":"description","type":"textarea"}]');

// Define a button 'published' with specific attributes and conditions
$xcrud->button(
    '#', 
    'published', 
    'icon-checkmark glyphicon glyphicon-ok', 
    'xcrud-action', 
    array(
        // Set data attributes for the button
        'data-task' => 'action',
        'data-action' => 'unpublish',
        'data-form' => 'true',
        'data-form-id' => '', // ID of HTML form (if applicable)
        'data-form-json' => $form, // JSON string of form definition
        'data-form-confirm-logic' => 'status==1', // Logic to confirm processing (process completes when 'status' equals '1')
        'data-form-confirm-logic-failure-message' => 'Could not process', // Message displayed if confirmation logic fails
        'data-primary' => '{id}' // Placeholder for primary key value
    ),
    array(
        // Set condition when the button should be shown (when 'bool' column equals '1')
        'bool',
        '=',
        '1'
    )
);

// Render the Xcrud instance
echo $xcrud->render();

?>

Base Fields

Search