geniv/nette-contact

Contact extension for Nette Framework

Installs: 124

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Language:HTML

v1.1.5 2018-12-21 22:20 UTC

This package is auto-updated.

Last update: 2020-09-22 02:17:12 UTC


README

Installation

$ composer require geniv/nette-contact

or

"geniv/nette-contact": "^1.0"

require:

"php": ">=7.0",
"nette/nette": ">=2.4",
"geniv/nette-general-form": ">=1.0"

Include in application

neon configure:

# contact form
contactForm:
#   autowired: true
#   formContainer: Contact\FormContainer
    events:
        - Contact\Events\EmailEvent
#        - Contact\Events\DibiEvent(%tablePrefix%)
        - ClearFormEvent
        - AjaxFlashMessageEvent

in case AjaxFlashMessageEvent is dependency: "geniv/nette-flash-message": ">=1.0"

neon configure extension:

extensions:
    contactForm: Contact\Bridges\Nette\Extension

usage:

protected function createComponentContactForm(ContactForm $contactForm, IEmailEvent $emailEvent): ContactForm
{
    $contactForm->setTemplatePath(__DIR__ . '/templates/Contact/contactForm.latte');
    $emailEvent->setTemplatePath(__DIR__ . '/templates/Contact/email.latte');
    $emailEvent->getMessage()
        ->addTo('example@gmail.com');

    $contactForm->onSuccess[] = function (array $values) {
        $this->flashMessage('odeslano', 'success');
//            $this['flashMessage']->redraw();
    };
    $contactForm->onException[] = function (EventException $e) {
        $this->flashMessage($e->getMessage(), 'danger');
    };
    return $contactForm;
}

usage:

{control contactForm}