alexlancer / Auto-CRUD-Generator-CodeIgniter-4-

MIT License
69 stars 36 forks source link

Error.... Need your help please #8

Open eddietohier opened 3 years ago

eddietohier commented 3 years ago

Undefined variable: affected

APPPATH/Libraries/Crud_core.php at line 398

391 $insertedFilesAffectedRows = false; 392 if ($filesData) { 393 foreach ($filesData as $fileDataKey => $fileDataOptions) { 394 $insertedFilesAffectedRows = $this->filesHandler($fileDataKey, $fileDataOptions); 395 } 396 } 397 398 if ($insertedFilesAffectedRows || $affected || $toDelete || $toInsert) 399 $this->flash('success', 'Successfully Updated'); 400 else 401 $this->flash('warning', 'The record was not updated or no changes were made'); 402 403 return ['redirect' => $this->base . '/' . $this->table . '/edit/' . $this->id]; 404 } else {

visserrobin commented 2 years ago

EDIT: It doesn't work with table links, I will look for another solution.......

I faced the same error and solved it by modifying Crud-core.php from line 307:

if ($this->action == 'add') { if (!$this->current_values) { $this->id = $this->model->insertItem($this->table, $post); if ($this->id) { $this->flash('success', 'Successfully Added'); return ['redirect' => $this->base . '/' . $this->table . '/edit/' . $this->id]; } }

I didn't fully test it yet, but it seems to save uploaded files too.....