Code in the view, this is being copied straight from the docs and is not working.
// app -> Cells -> DropdownCell.php
namespace App\Cells;
use CodeIgniter\View\Cells\Cell;
class DropdownCell extends Cell
{
protected $surveys;
public function courses($params): string
{
$this->surveys = model('SurveyModel');
$courses = $this->surveys->getUserCourses(auth()->user());
$data['items'] = [];
foreach ($courses as $c) {
$data['items'][] = ['id' => $c->id, 'title' => $c->title];
}
return view('components/dropdown',$data);
}
}
View:
<?= view_cell('DropdownCell::courses', ['type' => 'test']) ?>
I am getting an error:
Too few arguments to function App\Cells\Dropdown::courses(), 0 passed
I can't see what is going wrong with this? The dropdown cell has been made with Spark as per the doc guidelines. This is being served by a controller extending BaseController.
I should add that the view cell works fine if I don't use parameters, I would just like to use them...
I was trying to use the logic behind a 'simple cell' however the method I found that worked was following the instructions for 'computed cell'