| 49 | | $this->Poll->create(); |
| 50 | | |
| 51 | | if ( $this->Poll->save($this->data['Poll'])) |
| 52 | | { |
| 53 | | $this->Poll->id = false; |
| 54 | | $this->Pollrow->id = false; |
| 55 | | |
| 56 | | $poll_id = $this->Poll->getLastInsertID(); |
| 57 | | |
| 58 | | $colors = array('green', 'blue', 'brown', 'yellow', 'orange', 'red', 'black'); |
| 59 | | |
| 60 | | $i = 0; |
| 61 | | |
| 62 | | foreach($this->data['Row'] as $pollrow) |
| 63 | | { |
| 64 | | if ( strlen($pollrow) > 0 ) |
| 65 | | { |
| 66 | | if ( !$this->Pollrow->save(array('Pollrow' => array('answer' => $pollrow, 'poll_id' => $poll_id, 'color'=>$colors[$i], 'id'=>false) ) ) ) |
| 67 | | { |
| 68 | | die("Error " . $pollrow . "<br />" . $poll_id . "<br />"); |
| 69 | | } |
| 70 | | } |
| 71 | | $i++; |
| 72 | | } |
| 73 | | |
| 74 | | $this->msgFlash('Poll saved', '/admin/polls/listing'); |
| 75 | | |
| 76 | | } |
| 77 | | else |
| 78 | | { |
| 79 | | $this->flash('/admin/polls/listing', 'Error Pollrow model'); |
| 80 | | } |
| 81 | | } |
| | 45 | if ( $this->Poll->save($this->data)): |
| | 46 | $this->Poll->id = false; |
| | 47 | $this->Pollrow->id = false; |
| | 48 | $poll_id = $this->Poll->getLastInsertID(); |
| | 49 | $colors = array('green', 'blue', 'brown', 'yellow', 'orange', 'red', 'black'); |
| | 50 | $i = (int) 0; |
| | 51 | |
| | 52 | foreach($this->data['Row'] as $pollrow): |
| | 53 | if ( strlen($pollrow) > 0 ): |
| | 54 | |
| | 55 | $this->data['Pollrow'] = array('answer' => $pollrow, 'poll_id' => $poll_id, 'color'=>$colors[$i], 'id'=>false); |
| | 56 | |
| | 57 | if (!$this->Poll->Pollrow->save($this->data)): |
| | 58 | die("Error " . $pollrow . "<br />" . $poll_id . "<br />"); |
| | 59 | endif; |
| | 60 | endif; |
| | 61 | $i++; |
| | 62 | endforeach; |
| | 63 | endif; |
| | 64 | $this->msgFlash(__('Poll saved', true), '/admin/polls/listing'); |
| | 65 | endif; |