Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. public function add()
  2. {
  3.  
  4. $job = $this->Jobs->newEntity();
  5. if ($this->request->is('post')) {
  6. $job = $this->Jobs->patchEntity($job, $this->request->getData());
  7. $job->user_id = $this->Auth->user('id');
  8. if ($this->Jobs->save($job)) {
  9. $this->Flash->success(__('Job hasbeen saved'));
  10.  
  11. return $this->redirect(['action' => 'index']);
  12. }
  13. $this->Flash->error(__('Please try again'));
  14. }
  15.  
  16. $categories = $this->Jobs->Categories->find('list');
  17. $users = $this->Jobs->Users->find('list');
  18. $types = $this->Jobs->Types->find('list');
  19. $this->set(compact('job', 'categories', 'users', 'types'));
  20. $this->set('_serialize', ['job']);
  21. }
  22.  
  23. view
  24.  
  25.  
  26. <div class="col_12 column">
  27. <form id="reg_form">
  28. <fieldset>
  29. <legend><?= __('Add Job') ?></legend>
  30. <?php
  31. echo $this->Form->create($job);
  32. echo $this->Form->control('category_id', ['options' => $categories]);
  33. echo $this->Form->control('user_id', ['options'=>$users]);
  34. echo $this->Form->control('type_id', ['options' => $types]);
  35. echo $this->Form->control('company_name');
  36. echo $this->Form->control('title');
  37. echo $this->Form->control('description');
  38. echo $this->Form->control('area');
  39. echo $this->Form->control('city');
  40. echo $this->Form->control('contact_email');
  41. echo $this->Form->button(__('Submit'));
  42. echo $this->Form->end();
  43. ?>
  44. </fieldset>
  45. </form>
  46. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement