1. Go to this page and download the library: Download geniv/nette-general-form 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/ */
geniv / nette-general-form example snippets
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()
class MyForm extends Control implements ITemplatePath
...
public function setTemplatePath(string $path)
{
$this->templatePath = $path;
}
$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');
}
};
class RegistrationEmailNotifyEvent extends EmailNotifyEvent {}
class ForgottenEmailNotifyEvent extends EmailNotifyEvent {}
$emailNotifyEvent->onConfigure[] = function (IEventContainer $eventContainer, array $value) use ($emailNotifyEvent) {
$emailNotifyEvent->setTemplatePath(__DIR__ . '/templates/Forgotten/emailFormForgotten.latte');
$message = $emailNotifyEvent->getMessage();
$message->setFrom('[email protected]');
$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('[email protected]');
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 protected]');
break;
}
};