PHP code example of miloslavkostir / dialog-control
1. Go to this page and download the library: Download miloslavkostir/dialog-control 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/ */
miloslavkostir / dialog-control example snippets
protected function createComponentDialog(){
return new \MiloslavKostir\DialogControl\DialogControl;
}
// presenter
public function defaultAction(){
$this->getComponent('dialog')->init('show-message', function($dialog){
$dialog->message('Hello world')->open();
});
}
// presenter
public function defaultAction(){
if(!$this->user->isLoggedIn()){
// You can write init(NULL, function($dialog){...}); or just init(function($dialog){...});
$this->getComponent('dialog')->init(NULL, function($dialog){
$dialog->message('You are'n logged in', 'error')->open();
});
}
}
$this->getComponent('dialog')->init(NULL, function($dialog){
$dialog->html(Nette\Utils\Html::el('span')->setClass('error')->setText('This is error')); // adds HTML element (see Nette\Utils\Html)
$dialog->message('In fact, message() is shortcut for html()', 'error', 'span'); // the same as html() above
$dialog->control($this['myForm']); // adds control for instant render
$dialog->open(); // opens window and render all set elements
}
namespace Components;
use Nette;
class AdvancedDialogControl extends \MiloslavKostir\DialogControl\DialogControl {
protected function configure($presenter){
$this->block('advancedDialog', __DIR__.'/advancedDialogControl.latte');
$this->open();
}
protected function createComponentSomeForm(){
$form = new Nette\Application\UI\Form;
$form->addText('name', 'Your name');
$form->addSubmit('submit');
$form->onSuccess[] = $this->someFormSucceeded;
return $form;
}
public function someFormSucceeded($form){
$this->presenter->flashMessage('My name is '.$form->value->name);
$this->redirect('this');
}
}
protected function createComponentAdvancedDialog(){
return new \Components\AdvancedDialogControl();
}
public function defaultAction(){
$this->getComponent('advancedDialog')->init('show');
// or trigger
if(!$this->user->isLoggedIn()){
$this->getComponent('advancedDialog')->init();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.