我努力获得一种形式的工作方式,我希望它的行为。 我有一个区域和属性模型,一个区域可以有很多属性,等等...cakePHP:与相关模型的形式不automagic更新
我创建了一个窗体来选择区域,然后在该区域的属性!
在窗体具有两个列表,但我很难有第二列表[属性]与仅在该区域已经从第一列表[区域]中选择的属性更新AUTOMAGIC
当选择一个不同的区域在列表中,它应该更新automagic的属性列表,所以你只能看到该地区的属性!对不起,我的解释不好,但不知道如何解释这个更好。
这是在我的控制器的代码:
// Retrieve the region list
$this->set('regions', $this->Region->find('list', array(
'fields' => array('Region.id', 'Region.regionname'),
'order' => 'regionname',
)));
// Retrieve Property list for the regions.
$this->set('properties', $this->Region->Property->find('list', array(
'conditions' => array('Property.live' => true),
'fields' => array('Property.id','Property.description'),
'order' => 'id',
)));
这是我的形式的一部分。
<?php echo $this->Form->create('Upload', array('action' => 'add', 'type' => 'file')); ?>
<?php echo $this->Form->input('region_id', array('label' => 'Select Region:')); ?>
<?php echo $this->Form->input('property_id', array('label' => 'Select Property:')); ?>
<?php echo $this->Form->file('file'); ?>
我花了很多时间在这里和在YouTube上环顾四周,却找不到它:-(