大家好 CakePhp 开发人员,
CakePHP 2.5.2
我有一个带Agreements
表的数据库。它属于成人、儿童、团体、价格和课程表。
我的控制器有 3 个动作index
:add
和edit
。第一个index
工作正常,在一页中显示所有相关表格。但问题在于编辑和添加操作。
我的Controller有相关数据的数组,它的数组没有Children、Adults、Groups等真实姓名。只有数字 1、2、3 等。
我的 AgreementsController.php 通过以下命令向 View 发送数据:
$this->Agreement->recursive = 1;
$adults = $this->Agreement->Adult->find('list');
$childrens = $this->Agreement->Children->find('list');
$groups = $this->Agreement->Group->find('list');
$prices = $this->Agreement->Price->find('list');
$courses = $this->Agreement->Course->find('list');
$this->set(compact('adults', 'childrens', 'groups', 'prices', 'courses'));
我认为这个数组 $adults, $children 只有数字。为什么他们不检索真实的项目编号。我的协议/add.ctp 是:
<?php echo $this->Form->create('Agreement'); ?>
<?php
echo $this->Form->input('date_of_agreement');
echo $this->Form->input('number');
echo $this->Form->input('year');
echo $this->Form->input('adult_id', array (
'type' => 'select',
'options' => $adults
)
);
print_r($adults);
echo $this->Form->input('children_id');
echo $this->Form->input('status_id');
echo $this->Form->input('city_id');
echo $this->Form->input('price_id');
echo $this->Form->input('course_id');
echo $this->Form->input('group_id');
?>
<?php echo $this->Form->end(__('Submit')); ?>
即使添加“选项”参数也不能解决问题。我已经花了50小时,我不知道为什么?
我检查了数组,它看起来像这样: Array ( [1] => 1 [2] => 2 )
你能帮我解决这个问题吗?