Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带递归2的cakephp选择框_Php_Cakephp 1.3_Drop Down Menu - Fatal编程技术网

带递归2的cakephp选择框

带递归2的cakephp选择框,php,cakephp-1.3,drop-down-menu,Php,Cakephp 1.3,Drop Down Menu,我有Tarifs,每个Tarifs都有许多价格和价格也属于用户组。所以基本上,当用户组发生变化时,价格也会发生变化——这没什么大不了的 景色是这样的 <?php echo $this->Form->create('Tarif');?> ... $i=0; foreach ($this->data['Price'] as $price) { echo "<tr><td>".$th

我有
Tarifs
,每个Tarifs
都有许多
价格
价格
也属于
用户组
。所以基本上,当用户组发生变化时,价格也会发生变化——这没什么大不了的

景色是这样的

<?php echo $this->Form->create('Tarif');?>
    ...
        $i=0;
        foreach ($this->data['Price'] as $price) {

            echo "<tr><td>".$this->Form->input("Price.$i.price", array('label' => false))."</td>";
            echo "<td>".$this->Form->input("Price.$i.currency", array('label' => false))."</td>";
            echo "<td>".$this->Form->input("Price.$i.UserGroup.id", array('label' => false))."</td>";
    ...     

...
$i=0;
foreach($此->数据['Price']作为$Price){
回显“$this->Form->input(“Price.$i.Price”,数组('label'=>false));
回显“$this->Form->input(“Price.i.currency”,数组('label'=>false));
echo“$this->Form->input(“Price.i.UserGroup.id”,数组('label'=>false));
...     
我需要将
UserGroup.id
输入显示为select,其中每个选项都显示组名并将其
id
作为值。user\u group\id值很好,但以文本输入方式显示。我尝试了
$this->Form->select
$this->Form->input(…,'type'=>'select'))
但它们都提供了没有选项的选择框。 如何设置输入以执行所需操作?
谢谢

在控制器中,您需要添加:

$user_groups = $this->UserGroup->find('list');
$this->set(compact('user_groups');
然后在视图中设置下拉列表,如下所示:

<?php echo $this->Form->input('user_group', array('options' => $user_groups)); ?>
你能添加pr($price);并向我们展示你的一个数组吗?你的$this->form->input(数组('type'=>'select','option'=>$price['UserGroup']['name']))是正确的;注:这是一个盲目的回答。
array('options' => $user_groups)