Hello CakePhp developers,
CakePHP 2.5.2
I have a database with an Agreements
table. It belongs to Adults, Children, Groups, Prices and Courses tables.
My Controller has 3 actions: index
, add
and edit
.
The first one, index
, works fine, displays all related tables in one page.
But problem is with the edit and add actions.
My Controller has arrays with related data, and its arrays do not have real names of Children, Adults, Groups and so on. Only the numbers 1,2,3, etc.
My AgreementsController.php is sending data to View by this commands:
$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'));
I think that this arrays $adults, $children, have only numbers. Why they do not retrieve real item numbers. My Agreements/add.ctp is:
<?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')); ?>
Even adding 'options' parameter is not solving problem. I've spent 50h on that and i do not know why?
I have inspected array it looks like this : Array ( [1] => 1 [2] => 2 )
Can you help me with this?