0
我需要從模型中獲取多個記錄,然後將它們放入請求 - >數據,以便將視圖呈現爲具有多個輸入字段集的表單,例如name ='data [Applicant] [0] [DISPLAY_NAME]」。 name ='data [申請人] [1] [display_name]'...每個申請人都有數據價值。cakephp多個記錄數據數組適合請求數據
其實我已經做了我想要的東西,但我不認爲這是一個很好的方法。 明白,如果任何人都可以引導我
foreach ($this->Applicant->data['Applicant'] as $key=>$item){
$data['Applicant'][] = $item['Applicant'];
}
$this->request->data = $data;//set Model to data
$this->set('data' , $this->Applicant->data);
$這 - >申請人>數據如下:
Array
(
[Applicant] => Array
(
[0] => Array
(
[Applicant] => Array
(
[id] => 1
[application_id] => 17
[name] => User
[first_name] =>
...
)
)
[1] => Array
(
[Applicant] => Array
(
[id] => 3
[application_id] => 17
[name] =>
[first_name] =>
以下是所希望的輸出(以下一個電平):
Array
(
[Applicant] => Array
(
[0] => Array
(
[id] => 1
[application_id] => 17
[name] => User
[first_name] =>
...
)
[1] => Array
(
[id] => 3
[application_id] => 17
[name] =>
[first_name] =>
謝謝
它的工作原理。謝謝。 – horizon1711