CakePHP: 在$form->input中为控件绑定事件

1)选择框中选项变动事件:

echo $form->input('Deal.branch_id', array( 'type' => 'select',

        'multiple' => true,
        'options' => $branches,
        'selected' => $selected,
        'onchange' => 'change()',

));


2)为复选框中的每个选择添加onclick事件

需要重新定义options,否则无法工作

$options = array();
foreach($roles as $value => $label) {
  $options[] = array(
    'name' => $label,
    'value' => $value,
    'onClick' => 'showDiv(this)'
  );
}
echo $form->input('Role', array('type'=>'select',

        'options' => $options,
        'multiple'=>'checkbox',

));



你可能感兴趣的:(工作,input,cakephp)