DEMO SITE v1.7.26

Popup Selection Ajax NEW Minimal theme

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

#TextDateBool
1Test testYes published View Edit Remove
2Test28.09.2013Yes published View Edit Remove
3Test test test30.11.2032Yes published View Edit Remove
4TextYes published View Edit Remove
5ttt01.01.1970No unpublished View Edit Remove
Add Export into CSV Print Search Execution time: 0.005 sMemory usage: 0.18 MB