输入选择表单上的CakePHP标签选项无法按预期工作

Old*_*est 2 forms label cakephp helper

我的选择表单工作正常,但无论参数的变化或排列如何,我的标签都不会显示.

这是我的代码:

<?php echo $this->Form->input('plan_detail_id', $plans_list, array(
    'type' => 'select',
    'label' => 'Select a the Plan Detail',
    'empty' => '-- Select a the Plan Detail --'
)); ?>
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我有第二个参数$plan_list,通常是label标签的位置.例如,我的所有其他标签都可以:

<td><?php echo $this->Form->input('age_id', array(
    'label' => 'Select an Age Range',
    'empty' => '-- Select an Age Range --'
)); ?></td>
Run Code Online (Sandbox Code Playgroud)

注意:没有$argument像第一个例子那样的第二个例子.我做错了吗?或者这不可能或是一个错误?

joe*_*oeb 8

API不会向该FormHelper::input方法显示三个参数 ; 只有$fieldName$options.您可能打算使用该FormHelper::select方法.

$this->Form->select('plan_detail_id', $plans_list, null, array('label' => 'Select a the Plan Detail', 'empty' => '-- Select a the Plan Detail --'));
Run Code Online (Sandbox Code Playgroud)

请注意,FormHelper::select它不包括包装<div>或标签.要这样做,你必须传递这样的东西..

echo $this->Form->input(
    'plan_detail_id',
    array(
        'options' => $plans_list,
        'type' => 'select',
        'empty' => '-- Select a the Plan Detail --',
        'label' => 'Select a the Plan Detail'
    )
);
Run Code Online (Sandbox Code Playgroud)

这与您最初的尝试不同,因为它$plans_list使用options参数集移动到数组中.