Registrace – Formulář – Ke je v tomhle kodu chyba ( Rady prosím )
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- Mury
- Člen | 7
Co je na tomhle kodu špatně?
Díky za radu :p
<?php
namespace AdminModule\Forms;
use Nette\Application\UI;
class RegForm extends \BaseForm
{
/** @var \Nette\Security\User */
private $user;
public function __construct(\Nette\Security\User $user)
{
parent::__construct();
$this->user = $user;
$form = $this;
$form->addText('name', 'Jméno:')->setRequired('Please enter your name.');
$form->addText('surname', 'PĹ™ĂjmenĂ:')->setRequired('Please enter your surname.');
$form->addText('email', 'Email:')->setRequired('Please enter your username.');
$form->addPassword('password', 'Password:')->setRequired('Please enter your password.');
$form->addSubmit('send', 'Registrovat');
// call method signInFormSucceeded() on success
$form->onSuccess[] = $this->formSubmitted;
return $form;
}
public function pass($pass)
{
return sha1($pass);
}
public function formSubmitted($form)
{
$values = $form->getValues();
$data = array(
'first_name' => $values->name,
'last_name' => $values->surname,
'fullname' => $values->name.' '.$values->surname,
'email' => $values->email,
'password' => $this->pass($values->password),
'ins_dt' => new \DateTime()
);
$this->presenter->models->users->getTable()->insert($data);
$this->presenter->redirect('Homepage:');
}
}
?>