蛋糕php habtm select没有设置选定的值

时间:2013-03-05 08:24:53

标签: forms cakephp helper has-and-belongs-to-many

您好HABTM和Form有几个问题。 我正在使用CakePHP 2.3和PHP 5.3.3

这是我理解场景的代码情况:与HABTM关系相关的专辑和单曲。专辑共有很多单曲和单曲属于很多专辑。

Model Album.php(不关心葡萄干:是我个人管理图片的插件)

App::uses('Raisin', 'Raisins.Model');
App::uses('PastryBehavior', 'Raisins.Model/Behavior');

class Album extends AppModel
{
public $name = 'Album';

public $actsAs = array(
    'Tags.Taggable',
    'Utils.Sluggable' => array(
        'label'     => 'title'
    ),
    'Raisins.Pastry',
    'SrEngine.Indexable',
    'SrEngine.HitCounter'
);

public $hasOne = array(
    'Image' => array('className' => 'Raisins.Raisin')
);

public $hasAndBelongsToMany = array(

    'Single' 

);

public $belongsTo = array(
    'Users.User'
);

}

Controller AlbumsController.php(编辑部分)

$this->request->data = $this->Album->read(null, $id);
$this->set('singles',$this->Album->Single->find('list'));

查看

<?php echo $this->Form->input('Single',array('class' => 'span12','label' => 'Singoli' ) ); ?>

在视图中,我看到来自控制器单曲集的值填充的选项,但先前保存的所选项目未突出显示。 考虑在数据库中,habtm表包含填充了保存数据的正确行。 我读到,有些人在中间,有些先前版本的蛋糕,在2.3之前,曾经有一些与habtm形式选择输入有关的问题。 我非常坚持这一点,因为我几乎尝试了所有已知的解决方法而没有排序任何积极的影响。 任何帮助,暗示将非常感激。 提前致谢

鲁迪

0 个答案:

没有答案