Skip to content

Instantly share code, notes, and snippets.

@Majkl578
Created June 30, 2011 23:18
Show Gist options
  • Save Majkl578/1057527 to your computer and use it in GitHub Desktop.
Save Majkl578/1057527 to your computer and use it in GitHub Desktop.
<?php
//presenter
protected function createComponentLoginForm($name)
{
$form = new NAppForm($this, $name);
$form->addText('username', 'Už. jméno')->setRequired();
$form->addPassword('password', 'Heslo')->setRequired();
$form->addSubmit('submitter', 'Přihlásit se');
$form->onSuccess[] = callback($this, 'loginFormSubmitted'); //5.2
}
public function loginFormSubmitted($form)
{
$values = $form->values;
try {
$this->getUser()->login($values->username, $values->password);
$this->getApplication()->restoreRequest($this->backlink);
$this->redirect('Homepage:');
} catch (NAuthenticationException $e) {
$this->flashMessage('Authentication failed', 'error');
}
}
{* latte šablona *}
<div id="login" >
{form loginForm}
<div class="inputl"><span>{label username /}</span>{input username}</div>
<div class="inputl"><span>{label password /}</span>{input password}</div>
<div class="inputs">{input submitter}</div>
{/form}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment