Bonjour,
Je ne paviens pas à avoirs un select normal...
Il m'affiche tout l'array de la variables $categories.
Dans la vue
<?= $this->Form->select('categories',$categories); ?>
Dans le controller:
$categories = $this->Categories->find()->where(['type' => 'support'])->toArray();
$this->set('categories', $categories);
Je ne voie pas ou est l'érreur j'ai bien suivis la doc de cakephp mais rien y faire...
Voila se que j'obtiens en debug($categories);
(int) 0 => object(Cake\ORM\Entity) {
'id' => (int) 9,
'name' => 'Support Technique',
'slug' => 'Support_Technique',
'post_count' => (int) 0,
'type' => 'support',
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[repository]' => 'Categories'
},
(int) 1 => object(Cake\ORM\Entity) {
'id' => (int) 10,
'name' => 'Support Commercial',
'slug' => 'Support_Commercial',
'post_count' => (int) 0,
'type' => 'support',
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[repository]' => 'Categories'
}
et mon select me sort ceci :
<select name="categories"><option value="0">{
"id": 9,
"name": "Support Technique",
"slug": "Support_Technique",
"post_count": 0,
"type": "support"
}</option><option value="1">{
"id": 10,
"name": "Support Commercial",
"slug": "Support_Commercial",
"post_count": 0,
"type": "support"
}</option></select>
Si qu'elle qu'un a une idée :)
Merci