PHPackages                             geniv/nette-general-form - 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. geniv/nette-general-form

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

geniv/nette-general-form
========================

Form general class for Nette Framework

v1.1.6(7y ago)023.6k↓39.6%20MITPHPPHP &gt;=7.0

Since Feb 13Pushed 7y ago1 watchersCompare

[ Source](https://github.com/geniv/nette-general-form)[ Packagist](https://packagist.org/packages/geniv/nette-general-form)[ RSS](/packages/geniv-nette-general-form/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (19)Used By (20)

Nette general form
==================

[](#nette-general-form)

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

[](#installation)

```
$ composer require geniv/nette-general-form
```

or

```
"geniv/nette-general-form": "^1.1"
```

require:

```
"php": ">=7.0",
"nette/application": ">=2.4",
"nette/component-model": ">=2.3",
"nette/di": ">=2.4",
"nette/mail": ">=2.4",
"nette/utils": ">=2.4",
"tracy/tracy": ">=2.4"
```

Include in application
----------------------

[](#include-in-application)

usage *IEvent*:

```
class MyEvent implements IEvent

...

public function update(IEventContainer $eventContainer, array $values)

// usage method by IEventContainer
...
$eventContainer->getForm()
$eventContainer->addValues($values)
$eventContainer->setValues($values)
$eventContainer->removeValue($key)
$eventContainer->getComponent()
$eventContainer->getEventIndex()
$eventContainer->getEvents()
```

usage *IFormContainer* and *IEventContainer* (can use magic `__invoke` method):

```
private $formContainer;
private $eventContainer;
public $onSuccess, $onException;

public function __construct(IFormContainer $formContainer, array $events)

...

// $this->eventContainer = EventContainer::factory($this, $events, 'onSuccess', 'onException');
$this->eventContainer = EventContainer::factory($this, $events);
$this->formContainer = $formContainer;

...

$form->onSuccess[] = $this->eventContainer;
```

or *the old way* without `__invoke`:

```
try {
    $this->notify($form, $values);
    $this->onSuccess($values);
} catch (EventException $e) {
    $this->onException($e);
}
```

usage *ITemplatePath* (without return type!):

```
class MyForm extends Control implements ITemplatePath

...

public function setTemplatePath(string $path)
{
    $this->templatePath = $path;
}
```

Events for use (implements `IEvent`)
------------------------------------

[](#events-for-use-implements-ievent)

```
- DumpEvent
- FireLogEvent
- ClearFormEvent
- SetValueEvent     (setValues(array))
- CallbackEvent     (onCallback(IEventContainer, array))
- EmailNotifyEvent  (getMessage(), setTemplatePath(string))
```

### SetValueEvent

[](#setvalueevent)

```
- SetValueEvent([active: false, role: guest])
```

### CallbackEvent

[](#callbackevent)

```
- CallbackEvent
```

usage in presenter:

```
$callbackEvent->onCallback[] = function (IEventContainer $eventContainer, array $value) {
    if ($this->identityModel->existLogin($value['login'])) {
        throw new EventException('duplicate login');
    }

    if ($this->identityModel->existEmail($value['email'])) {
        throw new EventException('duplicate email');
    }
};
```

### EmailNotifyEvent

[](#emailnotifyevent)

```
admin: Identity\Events\RegistrationEmailNotifyEvent     # email for admin
user: Identity\Events\RegistrationEmailNotifyEvent      # email for user
# or
- Identity\Events\ForgottenEmailNotifyEvent
```

where self class name (prevents multiple services in *DI*):

```
class RegistrationEmailNotifyEvent extends EmailNotifyEvent {}
class ForgottenEmailNotifyEvent extends EmailNotifyEvent {}
```

usage in presenter:

```
$emailNotifyEvent->onConfigure[] = function (IEventContainer $eventContainer, array $value) use ($emailNotifyEvent) {
    $emailNotifyEvent->setTemplatePath(__DIR__ . '/templates/Forgotten/emailFormForgotten.latte');

    $message = $emailNotifyEvent->getMessage();
    $message->setFrom('info@email.cz');

    $message->setSubject('informacni email pro uzivatele');
    $message->addTo($value['email']);
};

// or

$emailNotifyEvent->onConfigure[] = function (IEventContainer $eventContainer, array $value) use ($emailNotifyEvent) {
    $message = $emailNotifyEvent->getMessage();
    $message->setFrom('info@email.cz');

    switch ($eventContainer->getEventIndex()) {
        case 'user':
            $emailNotifyEvent->setTemplatePath(__DIR__ . '/templates/Registration/emailFormUser.latte');

            $message->setSubject('informacni email pro uzivatele');
            $message->addTo($value['email']);
            break;

        case 'admin':
            $emailNotifyEvent->setTemplatePath(__DIR__ . '/templates/Registration/emailFormAdmin.latte');

            $message->setSubject('informacni email pro admina');
            $message->addTo('email@email.com');
            break;
    }
};
```

event in definition is possible use several times, and define like anonymous index or text index

```
events:
    - DumpEvent
    - DumpEvent
    fire1: FireLogEvent
    fire2: FireLogEvent
```

Extension
---------

[](#extension)

usage *GeneralForm*:

```
$formContainer = GeneralForm::getDefinitionFormContainer($this);
$events = GeneralForm::getDefinitionEventContainer($this);
```

usage *GeneralControl*:

```
class MyForm extends GeneralControl {

    public function __construct(IFormContainer $formContainer, array $events, ITranslator $translator = null)
    {
        parent::__construct($formContainer, $events, $translator);

        $this->templatePath = __DIR__ . '/MyPath.latte';    // set path
    }
}
```

Exception
---------

[](#exception)

class: `EventException`

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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

Every ~22 days

Recently: every ~73 days

Total

17

Last Release

2661d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.0.0

v1.1.6PHP &gt;=7.0

### Community

Maintainers

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

---

Top Contributors

[![geniv](https://avatars.githubusercontent.com/u/563659?v=4)](https://github.com/geniv "geniv (61 commits)")

---

Tags

eventnettecontentgeniveventContainerformContainer

### Embed Badge

![Health badge](/badges/geniv-nette-general-form/health.svg)

```
[![Health](https://phpackages.com/badges/geniv-nette-general-form/health.svg)](https://phpackages.com/packages/geniv-nette-general-form)
```

###  Alternatives

[contributte/event-dispatcher

Best event dispatcher / event manager / event emitter for Nette Framework

292.4M19](/packages/contributte-event-dispatcher)[contributte/menu-control

Menu control for Nette framework

29108.6k1](/packages/contributte-menu-control)[carrooi/nette-menu

Menu control for Nette framework

2950.0k1](/packages/carrooi-nette-menu)[bileto/cronner

Simple tool which helps with maintenance of cron tasks.

752.1k](/packages/bileto-cronner)

PHPackages © 2026

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