Forms FormHelper奇怪输入CakePhp
我和FormHelper有麻烦了 我有我的第一个模型“游戏”。看起来是这样的:Forms FormHelper奇怪输入CakePhp,forms,cakephp,checkbox,Forms,Cakephp,Checkbox,我和FormHelper有麻烦了 我有我的第一个模型“游戏”。看起来是这样的: class Game extends AppModel{ public $hasMany = array('gamesauthors','gameseditors','gamesillustrators','gamesgametypes'); public $hasAndBelongsToMany = array("Author" => array('j
class Game extends AppModel{
public $hasMany = array('gamesauthors','gameseditors','gamesillustrators','gamesgametypes');
public $hasAndBelongsToMany =
array("Author" =>
array('joinTable' => 'gamesauthors'),
"Editor" =>
array('joinTable' => 'gameseditors'),
"Illustrator" =>
array("joinTable" => 'gamesillustrators'),
"Gametype" =>
array('joinTable' => 'gamesgametypes'));
public $belongsTo = array('Collection','Distributor');
}
当我试图使“游戏类型”显示为带有该代码的复选框时:
<?= $this->Form->input('gametypes', array("label" => "Type(s) de jeu:", 'option' => $types, 'multiple' => 'checkbox')); ?>
这是一个文本形式,而不是复选框
我真的不明白。这是唯一不能工作的东西。所有其他模型(作者、编辑…)都非常正确。。。我检查了我所有的代码多次。它和其他型号完全一样
如果需要的话,我可以发布更多的信息(var_dump、debug等等!)
如果有人有主意。。。求你了
谢谢各位看起来您正在数组中使用“and”,这可能会导致问题
$this->Form->input('gametypes', array(
'label' => 'Type(s) de jeu:',
'option' => $types,
'multiple' => 'checkbox'));
这对我来说很好。Nop…同样的问题。我真的不明白。所有其他字段都有完全相同的代码。只是这样做很愚蠢。顺便说一下,谢谢你是否使用$This->set()将$multiples的值从控制器传递到视图?您可以发布控制器代码并指定您正在调用的函数吗?
code
public function edit($id=false){$collections=$this->Game->Collection->find('list');$distributors=$this->Game->Distributor->find('list');$authors=$this->Game->Author->find('list'));$editors=$this->Game->Editor->find('list');$types=$this->Game->Game->Gametype->find('list');$this->set(压缩('collections','distributors','authors','editors','types','illustrators');)code
我的控制器中的函数终于找到了解决方案!!!我只是将“游戏类型”重命名为“类型”…愚蠢的事情。谢谢你的帮助!!