FriendsOfCake/cakephp-csvview

CSV file is empty when using get method, though Arrray has values

Jahed1 opened this issue · 1 comments

when i use find method it works fine.

public function exportdependants($id){

  $dependants = $this->Dependants->get($id);
  	
	$_header = ['Full Name','Relationship','Date Of Birth','Dependant Until','Gender'];
$_extract = array('full_name','relationship','date_of_birth','dependant_until','gender');
	
	$this->response->download('Dependants.csv');
	$_serialize = ['dependants'];
	
$this->set(compact('dependants','_serialize','_header','_extract'));

  		$this->viewBuilder()->className('CsvView.Csv');
	
	return;

}

I believe $dependants needs to be set in an array. Since its a single object, we can't extract the data for the row.