1. Go to this page and download the library: Download jaxon-php/jaxon-dialogs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jaxon-php / jaxon-dialogs example snippets
'dialogs' => [
'default' => [
'modal' => 'bootstrap', // Default library for modal dialogs
'alert' => 'jconfirm', // Default library for alerts
'confirm' => 'noty', // Default library for questions
],
'lib' => [
'uri' => 'https://cdn.jaxon-php.org/libs',
'use' => ['cute', 'toastr'], // Additional libraries in use
],
// Confirm options
'confirm' => [
'title' => 'Confirm', // The confirm dialog
'yes' => 'Oh Yes', // The text of the Yes button
'no' => 'No way', // The text of the No button
],
// Options for the Toastr library
'toastr' => [
'options' => [
'closeButton' => true,
'positionClass' => 'toast-top-center'
],
],
// Load a different version of the JQuery Confirm library from a different CDN
'jconfirm' => [
'uri' => 'https://cdnjs.cloudflare.com/ajax/libs',
'subdir' => 'jquery-confirm',
'version' => '3.3.2',
],
],
/**
* Show a modal dialog.
*/
public function show($title, $content, array $buttons, array $options = []);
/**
* Hide the modal dialog.
*/
public function hide();
public function showDialog()
{
// The dialog buttons
$buttons = [[
'title' => 'Close',
'class' => 'btn',
'click' => 'close'
]];
// The HTML content of the dialog
$content = "This modal dialog depends on application settings!!";
// The dialog specific options
$options = ['width' => 500];
// Show the dialog
$this->response()->dialog->show("Modal Dialog", $content, $buttons, $options);
}
/**
* Print a success message.
*/
public function success($message, $title = null);
/**
* Print an information message.
*/
public function info($message, $title = null);
/**
* Print a warning message.
*/
public function warning($message, $title = null);
/**
* Print an error message.
*/
public function error($message, $title = null);
public function save($formValues)
{
if(!$this->validator->valid($formValues))
{
$this->response()->dialog->title("Error")->error("Invalid input");
return;
}
$this->repository->save($formValues);
$this->response()->dialog->title("Success")->success("Data saved!");
}
/**
* Add a confirmation question to the request
*/
public function confirm($question, ...);
<select class="form-control" id="colorselect" name="colorselect" onchange="
echo rq('HelloWorld')->setColor(je('colorselect')->rd()->select())
->confirm('Set color to {1}?', je('colorselect')->rd()->select())
<select class="form-control" id="colorselect" name="colorselect" onchange="
echo rq('HelloWorld')->setColor(jq('#colorselect')->val())
->confirm('Set color to {1}?', jq('#colorselect')->val())
interface ModalInterface
{
}
interface AlertInterface
{
}
interface ConfirmInterface
{
}
use function Jaxon\Dialogs\dialog;
dialog()->registerLibrary(\Path\To\My\Plugin::class, 'myplugin');