Skip to content

Instantly share code, notes, and snippets.

@romaninsh
Created June 30, 2014 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romaninsh/ecd49e5717d659a771ed to your computer and use it in GitHub Desktop.
Save romaninsh/ecd49e5717d659a771ed to your computer and use it in GitHub Desktop.
<?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