Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. public function edit($herd_id = null)
  2. {
  3. if($herd_id == null)
  4. {
  5. // log error
  6. $this->Flash->success(__('No herd was selected.'));
  7. return $this->redirect(['action' => 'index']);
  8. }
  9. $herdimport = $this->Herdimports->find('all')->where(['herd_id'=>$herd_id]);
  10. if($herdimport->count() == 0)
  11. {
  12. $herdimport = $this->Herdimports->newEntity();
  13. }
  14.  
  15. if ($this->request->is(['patch', 'post', 'put'])) {
  16. $herdimport = $this->Herdimports->patchEntities($herdimport, $this->request->getData());
  17. $this->Herdimports->deleteAll(['herd_id'=>$herd_id]);
  18. if ($this->Herdimports->saveMany($herdimport)) {
  19. $this->Flash->success(__('The herdimport has been saved.'));
  20. return $this->redirect(['action' => 'index']);
  21. }
  22. $this->Flash->error(__('The herdimport could not be saved. Please, try again.'));
  23. }
  24. $this->set('herd_id', $herd_id);
  25. $this->set(compact('herdimport'));
  26. }
  27.  
  28. <?= $this->Form->create($herdimport) ?>
  29. <fieldset>
  30. <legend><?= __('Edit Herdimport') ?></legend>
  31. <? $i = 0; ?>
  32. <? foreach ($herdimport as $h) : ?>
  33. <div class="repeat">
  34. <?= $this->Form->hidden($i.'.herd_id'); ?>
  35. <?= $this->Form->control($i.'.num',['data-default'=>""]); ?>
  36. <?= $this->Form->control($i.'.date',['data-default'=>""]); ?>
  37. <?= $this->Form->control($i.'.origin',['data-default'=>""]);?>
  38. <?= $this->Form->control($i.'.weight',['data-default'=>""]); ?>
  39. <?= $this->Form->control($i.'.price',['data-default'=>""]); ?>
  40. </div>
  41. <? $i ++; ?>
  42. <? endforeach; ?>
  43.  
  44. <button class="extra-row"><?=__('Extra row');?></button>
  45. <button class="delete-row" style="display: none;"><?=__('Delete row');?></button>
  46.  
  47. </fieldset>
  48. <?= $this->Form->button(__('Submit')) ?>
  49. <?= $this->Form->end() ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement