PHPackages                             miloslavkostir/dialog-control - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. miloslavkostir/dialog-control

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

miloslavkostir/dialog-control
=============================

Modal windows for Nette Framework

v1.0(11y ago)041BSD-3PHPPHP &gt;=5.3.2

Since Mar 14Pushed 10y ago1 watchersCompare

[ Source](https://github.com/miloslavkostir/dialog-control)[ Packagist](https://packagist.org/packages/miloslavkostir/dialog-control)[ RSS](/packages/miloslavkostir-dialog-control/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

DialogControl
=============

[](#dialogcontrol)

DialogControl is component for create modal windows in [Nette Framework](http://nette.org/en/).

Requirements
------------

[](#requirements)

DialogControl requires Nette Framework 2.0.0 or higher and PHP 5.3 or later.

Installation
------------

[](#installation)

Install using composer:

```
$ composer require miloslavkostir/dialog-control

```

And load css files from vendor/miloslavkostir/dialog-control/resources.

Getting started
---------------

[](#getting-started)

1.Create control in presenter

```
protected function createComponentDialog(){
	return new \MiloslavKostir\DialogControl\DialogControl;
}
```

2.Put control into template

```
{control dialog}
```

Usage
-----

[](#usage)

\####Show "Hello world" in modal window You must init the window (the best place for init is action method) :

```
// presenter
public function defaultAction(){
	$this->getComponent('dialog')->init('show-message', function($dialog){
		$dialog->message('Hello world')->open();
	});
}
```

```

Show message
```

Click on "Show message" and you should see modal window.

\####Self-init or triggering The callback in second parameter of init() is execute when value of first parameter equal to value of parameter 'dialogDo' in query URL. It's self-initialization. But you can trigger the window by another event:

```
// 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();
		});
	}
}
```

\####Not just message Method message() isn't only one what you can use. Try this:

```
$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
}
```

\####Rendering block If you need to render window manualy, you can use method block(). First parameter is name of block, second parameter is path to file. Second parameter is optional, then you must specify directory with dialog templates in constructor.

```
$this->getComponent('dialog')->init('show-block', function($dialog){
	$dialog->block('loginDialog', 'path/to/loginDialog.latte')->open();
}
```

If you want to render control in this block, you must create control in DialogControl component. Use createControl() for it.

```
// presenter
protected function createComponentLoginForm(){
	$form = new \Nette\Application\UI\Form;

	$form->addText('login', 'Login');
	$form->addPassword('password', 'Password');
	$form->addSubmit('submit');
	...
	return $form;
}

$this->getComponent('dialog')->init('show-block', function($dialog){
	$dialog->block('loginDialog', 'path/to/loginDialog.latte')
			->createControl('loginForm', $this->createComponentLoginForm())
			->open();
}
```

```
{* template loginDialog.latte *}
{block loginDialog}
	Login
	{form loginForm}
		{label login}{input login}
		{label password}{input password}
		{input submit}
	{/form}
{/block}
```

\####Advanced useage Whole DialogControl is possible to move into own class. Then you will use method configure instead of callback

```
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');
	}

}
```

advancedDialogControl.latte

```
{block advancedDialog}
	Advanced usage of DialogControl
	{form someForm}
		{label name}{input name}
		{input submit}
	{/form}
{/block}
```

In presenter :

```
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();
	}
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4074d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c5c02f59c86548de7a80a9616a569d4daaaaca07c66ed75505a088988f53dc7e?d=identicon)[miloslavkostir](/maintainers/miloslavkostir)

---

Top Contributors

[![miloslavkostir](https://avatars.githubusercontent.com/u/5463235?v=4)](https://github.com/miloslavkostir "miloslavkostir (23 commits)")

---

Tags

nettedialog windowmodal windowdialog-control

### Embed Badge

![Health badge](/badges/miloslavkostir-dialog-control/health.svg)

```
[![Health](https://phpackages.com/badges/miloslavkostir-dialog-control/health.svg)](https://phpackages.com/packages/miloslavkostir-dialog-control)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[nette/php-generator

🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 8.5 features.

2.2k64.2M574](/packages/nette-php-generator)[nette/robot-loader

🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.

89152.7M320](/packages/nette-robot-loader)[vojtech-dobes/nette-forms-gpspicker

Google Maps based picker of coordinates for Nette Framework.

2456.6k](/packages/vojtech-dobes-nette-forms-gpspicker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
