Created
June 30, 2014 11:36
-
-
Save romaninsh/ecd49e5717d659a771ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Form_Register extends Form { | |
function init(){ | |
parent::init(); | |
$this->addField('Line','email')->validateNotNull(); | |
$this->addField('Password','password')->validateNotNull(); | |
$this->addSubmit('Register'); | |
$this->onSubmit(function($f) { | |
// Let's see if account with this email exists; | |
$m=$f->add('Model_User'); | |
if($m->tryLoadBy('email', strtolower($f['email']))->loaded()) | |
return $this->error('email','This email already exists. Use password reminder?'); | |
$f->add('Controller_Validator') | |
->is('email|email') | |
->is('password|len|>4?Password is too short') | |
->is('password|crack') | |
->now() | |
; | |
$this->add('Model_User')->register($this->get('email'),$this->get('password')); | |
return 'Thank you. Check your email to complete registration process.'; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment