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

发布于 2024-10-16 09:40:50 字数 644 浏览 10 评论 0原文

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

这是我的代码:

<?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 --'
)); ?>

如您所见,我有第二个参数 $plan_list 它通常是标签标记的位置。例如,我的所有其他类似标签都可以:

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

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

My select form is working perfectly, but my label will not display no matter the variation or arrangement of arguments.

Here is my code:

<?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 --'
)); ?>

As you can see I have a second argument $plan_list which is normally the place for the label tag. For example, all of my other labels like such are OK:

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

Note: there is no second $argument like the first example. Am I doing something totally wrong? Or is this not possible or a bug?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微凉 2024-10-23 09:40:50

API 不向 FormHelper 显示三个参数: :输入方法;只有 $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 --'));

请注意,FormHelper::select 不包含包装

或标签。为此,您必须传递类似这样的内容。

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'
    )
);

这与您最初的尝试不同,它将 $plans_list 移动到带有 options 参数集的数组中。

The API doesn't show three parameters to the FormHelper::input method; there is only $fieldName and $options. You probably meant to use the FormHelper::select method instead.

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

Note that the FormHelper::select does not include a wrapping <div> or label. To do so you must pass in something like this..

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'
    )
);

This differs from your original attempt in that it moves the $plans_list into the array with the options argument set.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文