Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function add_Employee(){
- $accounts=$this->User->find('list', array(
- 'fields'=>array('account_id'),
- 'conditions' => array(
- 'User.id' => $this->Auth->user('id'))));
- if($this->request->is('post')){
- $this->User->create();
- if ($this->User->save($this->request->data))
- {
- $this->Session->setFlash('The user has been saved');
- $this->redirect( array('controller'=>'Users','action' => 'index_admin'));
- }
- else { $this->Session->setFlash('The user could not be saved. Please, try again.'); }
- }
- $this->set('accounts',$accounts);
- }
- <h2>Add Employee</h2>
- <p>Add a new Employee here, please enter their details below.</p>
- <?php
- echo $this->Form->create('User', array('action'=>'add_Employee'));
- echo $this->Form->input('username',array('label'=>'Username: '));
- echo $this->Form->input('password',array('label'=>'Password: '), array('type'=>'password'));
- echo $this->Form->input('password_confirmation',array('label'=>'Confirm: '), array('type'=>'password'));
- echo $this->Form->input('email',array('label'=>'Email: '));
- echo $this->Form->input('title',array('label'=>'Title: '));
- echo $this->Form->input('firstname',array('label'=>'First Name: '));
- echo $this->Form->input('surname',array('label'=>'Surname: '));
- echo $this->Form->input('active', array('default'=>true, 'type'=>'hidden'));
- echo $this->Form->input('account_id', array('value'=>$accounts['User']['account_id']));
- echo $this->Form->input('access_level', array(
- 'label' => 'Access Level:',
- 'options' => array('1'=>'Employee','2'=>'Adminstrator')));
- echo $this->Form->end('Submit');
- ?>
- In controller:
- $accounts=$this->User->find('first', array(
- 'conditions' => array(
- 'id' => $this->Auth->user('id'))));
- $this->set('account',$accounts);
- In view :
- echo $this->Form->input('account_id', array('label'=>'Account','value'=>$account['User']['account_id']));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement