0
AvadiariesTable.php検索(リスト)いくつかのブランクのオプションを返し、検索(すべて)は、正しいデータを返しているが、なぜ{
$this->belongsTo('AlumnesGrups', [
'foreignKey' => 'alumnes_grup_id',
'joinType' => 'INNER'
AlumnesGrupsTable.php
$this->belongsTo('Alumnes', [
'foreignKey' => 'alumne_id',
'joinType' => 'INNER'
]);
$this->belongsTo('Grups', [
'foreignKey' => 'grup_id',
'joinType' => 'INNER'
]);
でフォーマットAvadiariesController.php:
public function add()
{
$avadiary = $this->Avadiaries->newEntity();
if ($this->request->is('post')) {
$avadiary = $this->Avadiaries->patchEntity($avadiary, $this->request->data);
$avadiary->user_id = $this->Auth->user('id');
if ($this->Avadiaries->save($avadiary)) {
$this->Flash->success(__('The avadiary has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The avadiary could not be saved. Please, try again.'));
}
}
$alumnesGrups = $this->Avadiaries->AlumnesGrups->find('all', [
'fields' => ['Alumnes.name'],
'contain' =>['Alumnes', 'Grups'],
'conditions' => ['Grups.id =' => 1],
'order' => ['Alumnes.name' => 'ASC']
]);
$this->set(compact('avadiary', 'alumnesGrups'));
$this->set('_serialize', ['avadiary']);
}
正しいデータが返されますが、次のようにフォーマットされます。
{「名前」:「アンジェラスミス」}}?
私はちょうどアンジェラスミスを得ることができますか? find(all)をfind(list)に変更すると、selectboxには空白のオプションがいくつか表示されます。
ありがとうございました!
はどうもありがとうございましたが、私はすでにこれを試してみました、値がでている保ちますブランク。また、app.phpのデータソースセクションでエンコーディングがOKかどうかを確認しました。 –
私は現在Hash :: extractで試していますが、致命的なエラーが発生します。Class Hash not found。 –
'find( 'list')' – arilia