Example #1
0
 public function login()
 {
     if ($this->auth->logged_in()) {
         $form = new Formation('auth_demo/logout', 'Log Out');
         $form->submit('Logout Now');
     } else {
         $form = new Formation(NULL, 'User Login');
         $form->input('email')->label(true)->rules('required|length[4,32]');
         $form->password('password')->label(true)->rules('required|length[5,40]');
         $form->submit('Attempt Login');
         if ($form->validate()) {
             // Load the user
             $user = new Model_User($form->email->value);
             // Attempt a login
             if ($this->auth->login($user, $form->password->value, true)) {
                 echo '<h4>Login Success!</h4>';
                 $form = new Formation('auth_demo/logout', 'Log Out');
                 $form->submit('Logout Now');
             } else {
                 $form->password->add_error('login_failed', 'Invalid username or password.');
             }
         }
     }
     // Display the form
     echo $form->render();
 }
Example #2
0
 public function upload()
 {
     $profiler = new Profiler();
     $form = new Formation();
     $form->input('hello')->label(YES);
     $form->upload('file', YES)->label(YES)->rules('required|size[200KB]|allow[jpg,png,gif]');
     $form->submit('Upload');
     if ($form->validate()) {
         echo Eight::debug($form->as_array());
     }
     echo $form->render();
 }