CakePHP从输入选择中获取id值

时间:2015-02-24 15:36:04

标签: cakephp-2.0

我有CelebrantCelebration模型,其中Celebrant有N Celebration。我正在填充一个输入选择,以查看庆祝添加,列出所有注册的Celebrant。在此之前,问题在于,当您提交表单时,select的值将作为选择查看位置的数量而来,我想来Celebrant ID。

这就是我的所作所为:

CelebrationsController

$this->set('celebrants', $this->Celebration->Celebrant->find('list')); 

查看/庆典/添加

echo $this->Form->input('celebrant_id', array('type' => 'select', 'label'=>'Celebrante', 'options' => $celebrants, 'empty' => __( 'Selecione um Celebrante' )));

模型/礼

var $hasMany = array(
    'Celebration' => array(
        'className'    => 'Celebration',
        'foreignKey'    => 'celebrant_id'
     )
);

模型/庆祝

var $belongsTo = array(
    'Celebrant' => array(
        'className'    => 'Celebrant',
        'foreignKey'    => 'celebrant_id'
     )
);

0 个答案:

没有答案