Hi! I need some help.
I must generate a option select like this
<select name="data[Emissfattura][datasel]" onchange="javascript: document.DataFatt.submit();" id="EmissfatturaDatasel">
<option value="">(Seleziona una data)</option>
<option value="15-12-2021">15-12-2021</option>
<option value="31-08-2021">31-08-2021</option>
<option value="30-06-2021">30-06-2021</option>
</select>
`
In my controller I try
$this->set('results', $this->Fatturazionidate->find('list', ['keyField' => 'data','valueField' => 'data','order'=>'Fatturazionidate.data desc' ])->all()->distinct('data'));
but the same key and value in the array don’t work.
Inside my template
....
echo $this->Form->select('datasel',['options' => $results,'onchange'=>'javascript: document.DataFatt.submit();','empty' => '(Seleziona una data)','label'=>'Data']);
I try also a custom query
$connection = ConnectionManager::get('default');
$results = $connection->execute('SELECT distinct data, data FROM
fatturazionidateorder by data desc')->fetchAll('assoc');
but the output is not how I want it:
Array
(
[0] => Array
(
[data] => 2021-12-15
)
[1] => Array ( [data] => 2021-08-31 ) .....
Thank you if someone helps me
Davide