Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Model File Code:
- <?php
- App::uses('Model', 'Model');
- /**
- * Application model for Cake.
- *
- * Add your application-wide methods in the class below, your models
- * will inherit them.
- *
- * @package app.Model
- */
- class User extends Model {
- public $name = 'User';
- public $validate = array(
- 'fname' => array(
- 'rule' => 'notEmpty',
- 'required' => true,
- 'message' => 'Please fill first name.'
- ),
- 'uname' => array(
- 'rule' => 'notEmpty',
- 'required' => true,
- 'message' => 'Please fill Username name.'
- ),
- 'email' => array(
- 'rule' => 'notEmpty',
- 'required' => true,
- 'message' => 'Please fill email.'
- ),
- 'phone' => array(
- 'rule' => 'notEmpty',
- 'required' => true,
- 'message' => 'Please fill phone.'
- ),
- 'roles' => array(
- 'rule' => 'notEmpty',
- 'required' => true,
- 'message' => 'Please fill one role atleast.'
- ),
- 'password' => array(
- 'rule' => 'notEmpty',
- 'required' => true,
- 'message' => 'Please fill password.'
- )
- );
- }
- View File Code:
- <?php
- /** registration form **/
- echo $this->Form->create('User', array('url' => array('controller' => 'users', 'action' => 'register'),'id' => 'registeration', 'class' => 'register', 'novalidate' => true));
- echo $this->Form->input('User.fname', array('label' => 'First Name:', 'id' => 'fname'));
- echo $this->Form->input('User.lname', array('label' => 'Last Name:'));
- echo $this->Form->input('User.uname', array('label' => 'User Name:', 'id' => 'uname'));
- echo $this->Form->input('User.email', array('label' => 'Email address:', 'id' => 'email'));
- echo $this->Form->input('User.phone', array('label' => 'Phone:', 'id' => 'phone'));
- echo $this->Form->input('User.address', array('label' => 'Address:'));
- echo $this->Form->input('User.roles', array(
- 'type' => 'radio',
- 'options' => array(1 => 'Customer', 2 => 'Vendor'), 'id' => 'roles'
- ));
- echo $this->Form->input('User.password', array('label' => 'Password:', 'id' => 'password'));
- echo $this->Form->input('User.cpassword', array('label' => 'Confirm Password:','type' => 'password', 'id' => 'cpassword'));
- echo $this->Form->end('Save');
- ?>
- Controller file is:
- <?php
- App::uses('AppController', 'Controller');
- class UsersController extends AppController {
- /**
- * This controller does not use a model
- *
- * @var array
- */
- public $uses = array('User');
- /**
- * Displays a view
- *
- * @return void
- * @throws NotFoundException When the view file could not be found
- * or MissingViewException in debug mode.
- */
- public function index() {
- }
- public function login() {
- //$this->layout = 'feedback';
- }
- public function register() {
- if($this->request->is('post')) {
- if($this->User->save( $this->request->data))
- {
- pr($this->request->data);
- die('save');
- } else {
- die('could not save');
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement