不确定这是否是满足我需要的最佳方式,但这是我的问题。在我的编辑功能视图中,我根据其中的内容重新创建表单字段,$this->data->expense
但我需要数组按特定顺序排列,否则字段会以错误的顺序生成。这是我拥有的数组:
'Expense' => array(
(int) 0 => array(
'id' => '98',
'date' => '2012-08-23',
'sitename' => '123',
'detail' => 'Breakfast',
'amount' => '100.00',
'miles' => null,
'total' => '100.00',
'expense_claim_id' => '63',
'created' => '2012-08-23 09:08:52',
'modified' => '2012-08-23 09:08:52',
'ExpenseClaim' => array(
'id' => '63',
'user_id' => '3',
'claim_status_id' => '1',
'created' => '2012-08-23 09:08:52',
'modified' => '2012-08-23 10:14:10',
'approved' => false,
'approved_by' => '0',
'date_submitted' => '2012-08-23 09:08:52'
),
'ExpenseCode' => array(
(int) 0 => array(
'id' => '1',
'name' => 'Plane fare',
'code' => '1',
'created' => '2012-07-31 09:52:02',
'modified' => '2012-07-31 09:53:57'
)
)
),
这就是我需要订购它的方式(ExpenseCode
)出现在更高的位置:
'Expense' => array(
(int) 0 => array(
'id' => '98',
'date' => '2012-08-23',
'sitename' => '123',
'detail' => 'Breakfast',
'ExpenseCode' => array(
(int) 0 => array(
'id' => '1',
'name' => 'Plane fare',
'code' => '1',
'created' => '2012-07-31 09:52:02',
'modified' => '2012-07-31 09:53:57'
)
),
'amount' => '100.00',
'miles' => null,
'total' => '100.00',
'expense_claim_id' => '63',
'created' => '2012-08-23 09:08:52',
'modified' => '2012-08-23 09:08:52',
'ExpenseClaim' => array(
'id' => '63',
'user_id' => '3',
'claim_status_id' => '1',
'created' => '2012-08-23 09:08:52',
'modified' => '2012-08-23 10:14:10',
'approved' => false,
'approved_by' => '0',
'date_submitted' => '2012-08-23 09:08:52'
)
),
我怎样才能做到这一点,并且在我发布时改变它的结构会影响蛋糕吗?