Commit 45a3dd5b authored by Mpro's avatar Mpro

Front implementation form for user service

parent 3a9e88d3
......@@ -4,6 +4,8 @@ namespace PigLatinTranslator\Presenters;
use Nette,
PigLatinTranslator\Model;
use Nette\Application\UI\Form;
use Kdyby\BootstrapFormRenderer\BootstrapRenderer;
/**
......@@ -12,9 +14,21 @@ use Nette,
class HomepagePresenter extends BasePresenter
{
public function renderDefault()
public function createComponentTranslatorForm()
{
$this->template->anyVariable = 'any value';
$form = new Form;
$form->setRenderer(new BootstrapRenderer);
$form->addText('text', 'Text:')
->setRequired('Zadejte prosím text.');
$form->addSubmit('translate', 'Přeložit');
$form->onSuccess[] = array($this, 'translatorFormSubmitted');
return $form;
}
public function translatorFormSubmitted($form)
{
$translator = $this->context->getByType('PigLatinTranslator\Services\ITranslator');
$this->template->translate = $translator->translate($form->values->text);
}
}
{block content}
{control translatorForm}
{if isset($translate)}
<h2>Překlad</h2>
<div>{$translate}</div>
{/if}
{/block}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment