Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo $this->Form->input('location');
- echo $this->Form->input('location_id', array('type' => 'select', 'options' => $CompanyLocations));
- public function add()
- {
- $user = $this->Users->newEntity();
- if ($this->request->is('post')) {
- $user = $this->Users->patchEntity($user, $this->request->data);
- if ($this->Users->save($user)) {
- $this->Flash->success(__('The user has been saved.'));
- return $this->redirect(['action' => 'index']);
- }
- $this->Flash->error(__('The user could not be saved. Please, try again.'));
- }
- $CompanyLocations= $this->Users->CompanyLocations->find('list');
- $this->set(compact('CompanyLocations'));
- $this->set(compact('user'));
- $this->set('_serialize', ['user']);
- $this->belongsTo('CompanyLocations');
- public function initialize(array $config)
- {
- parent::initialize($config);
- $this->table('company_locations');
- $this->displayField('location_name');
- $this->primaryKey('location_id');
- $this->belongsTo('Locations', [
- 'foreignKey' => 'location_id',
- 'joinType' => 'INNER'
- ]);
- }
- CREATE TABLE IF NOT EXISTS southpac_team.company_locations (
- location_id INT NOT NULL AUTO_INCREMENT,
- location_name VARCHAR(45) NULL,
- PRIMARY KEY (location_id))
- ENGINE = InnoDB;
- DROP TABLE IF EXISTS southpac_team.users ;
- CREATE TABLE IF NOT EXISTS southpac_team.users (
- id INT NOT NULL AUTO_INCREMENT,
- username VARCHAR(20) NOT NULL,
- password VARCHAR(255) NOT NULL,
- name VARCHAR(255) NOT NULL,
- department INT NULL,
- mobile VARCHAR(255) NULL,
- email VARCHAR(255) NULL,
- extension INT NULL,
- lame_number INT NULL,
- spa_auth_number VARCHAR(15) NULL,
- creation_date DATE NULL,
- picture VARCHAR(255) NULL,
- employed TINYINT(1) NOT NULL,
- location INT NOT NULL,
- PRIMARY KEY (id),
- INDEX get location_idx (location ASC),
- CONSTRAINT get location
- FOREIGN KEY (location)
- REFERENCES southpac_team.company_locations(location_id)
- ON DELETE NO ACTION
- ON UPDATE NO ACTION)
- ENGINE = InnoDB;
- echo $this->Form->input('company_location_id');
- $companyLocations= $this->Users->CompanyLocations->find('list');
- $this->set(compact('companyLocations'));
- $this->belongsTo('CompanyLocations', [
- 'foreignKey' => 'location'
- ]);
- company_locations.location_id > locations.primary_key
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement