CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 企业解决方案
  • 纪念品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题(Github)
    • 烘焙
    • 特色资源
    • 培训
    • 聚会
    • 我的CakePHP
    • CakeFest
    • 通讯
    • 领英
    • YouTube
    • 脸书
    • 推特
    • Mastodon
    • 帮助与支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

命名空间

  • 全局
  • Cake
    • 缓存
    • 集合
    • 命令
    • 控制台
    • 控制器
    • 核心
    • 数据库
    • 数据源
    • 错误
    • 事件
    • 表单
    • Http
    • I18n
    • 日志
    • 邮件
    • 网络
    • ORM
    • 路由
    • 测试套件
    • 实用程序
    • 验证
    • 视图
      • 异常
      • 表单
      • 助手
      • 小部件

类 MultiCheckboxWidget

用于生成多个复选框的输入小部件类。

此类通常由 Cake\View\Helper\FormHelper 内部使用,但也可以用于生成独立的多个复选框。

命名空间: Cake\View\Widget

属性摘要

  • $_idPrefix protected
    string|null

    ID 属性的前缀。

  • $_idSuffixes protected
    list<string>

    当前渲染中使用的 ID 后缀列表。

  • $_label protected
    Cake\View\Widget\LabelWidget

    标签小部件实例。

  • $_templates protected
    Cake\View\StringTemplate

    字符串模板实例。

  • $defaults protected
    array<string, mixed>

    数据默认值。

方法摘要

  • __construct() public

    渲染多选框小部件。

  • _clearIds() protected

    清除存储的 ID 后缀。

  • _domId() protected

    生成适合在 ID 属性中使用的 ID。

  • _id() protected

    为元素生成 ID 属性。

  • _idSuffix() protected

    生成 ID 后缀。

  • _isDisabled() protected

    用于确定哪些选项被禁用的辅助方法。

  • _isSelected() protected

    用于确定哪些选项被选中的辅助方法。

  • _renderInput() protected

    渲染单个复选框和包装器。

  • _renderInputs() protected

    渲染复选框输入。

  • mergeDefaults() protected

    将默认值与提供的數據合并。

  • render() public

    渲染多选框小部件。

  • secureFields() public

    返回此小部件需要安全保护的字段列表。

  • setMaxLength() protected

    如果适用,设置 "maxlength" 属性的值。

  • setRequired() protected

    如果适用,设置 "required" 属性的值。

  • setStep() protected

    如果适用,设置 "step" 属性的值。

方法详情

__construct() ¶ public

__construct(Cake\View\StringTemplate $templates, Cake\View\Widget\LabelWidget $label)

渲染多选框小部件。

此类使用以下模板

  • checkbox 渲染复选框输入控件。接受 name、value 和 attrs 变量。
  • checkboxWrapper 渲染复选框及其标签的包含 div/元素。接受 input 和 label 变量。
  • multicheckboxWrapper 渲染围绕分组输入的包装器。
  • multicheckboxTitle 渲染分组输入的标题元素。
参数
Cake\View\StringTemplate $templates

模板列表。

Cake\View\Widget\LabelWidget $label

标签小部件实例。

_clearIds() ¶ protected

_clearIds(): void

清除存储的 ID 后缀。

返回值
void

_domId() ¶ protected

_domId(string $value): string

生成适合在 ID 属性中使用的 ID。

参数
string $value

要转换为 ID 的值。

返回值
string

_id() ¶ protected

_id(string $name, string $val): string

为元素生成 ID 属性。

确保给定字段集的 ID 是唯一的。

参数
string $name

ID 属性名称。

string $val

ID 属性值。

返回值
string

_idSuffix() ¶ protected

_idSuffix(string $val): string

生成 ID 后缀。

确保给定字段集的 ID 是唯一的。

参数
string $val

ID 属性值。

返回值
string

_isDisabled() ¶ protected

_isDisabled(string $key, mixed $disabled): bool

用于确定哪些选项被禁用的辅助方法。

参数
string $key

要测试的键。

mixed $disabled

禁用的值。

返回值
bool

_isSelected() ¶ protected

_isSelected(string $key, list<string>|string|int|false|null $selected): bool

用于确定哪些选项被选中的辅助方法。

参数
string $key

要测试的键。

list<string>|string|int|false|null $selected

选中的值。

返回值
bool

_renderInput() ¶ protected

_renderInput(array<string, mixed> $checkbox, Cake\View\Form\ContextInterface $context): string

渲染单个复选框和包装器。

参数
array<string, mixed> $checkbox

包含复选框键/值选项对的数组

Cake\View\Form\ContextInterface $context

上下文对象。

返回值
string

_renderInputs() ¶ protected

_renderInputs(array<string, mixed> $data, Cake\View\Form\ContextInterface $context): list<string>

渲染复选框输入。

参数
array<string, mixed> $data

定义复选框的数据数组。

Cake\View\Form\ContextInterface $context

当前表单上下文。

返回值
list<string>

mergeDefaults() ¶ protected

mergeDefaults(array<string, mixed> $data, Cake\View\Form\ContextInterface $context): array<string, mixed>

将默认值与提供的數據合并。

参数
array<string, mixed> $data

数据数组

Cake\View\Form\ContextInterface $context

上下文实例。

返回值
array<string, mixed>

render() ¶ public

render(array<string, mixed> $data, Cake\View\Form\ContextInterface $context): string

渲染多选框小部件。

数据支持以下选项。

  • name 要创建的输入的 name 属性。[] 将附加到名称。
  • options 要创建复选框的选项数组。
  • val 字符串/整数或应该被选中的值的数组。也可以是复杂的选项集。
  • disabled 布尔值或要禁用的复选框数组。
  • escape 设置为 false 以禁用 HTML 转义。
  • options 一个关联数组,包含用于生成选项的值=>标签。
  • idPrefix 为生成的 ID 属性生成的前缀。

选项格式

options 选项可以根据您想要生成的 HTML 的复杂性,采用各种数据格式。

您可以使用基本的关联数组生成简单的选项

'options' => ['elk' => 'Elk', 'beaver' => 'Beaver']

如果您需要在选项元素上定义其他属性,可以使用选项的复杂形式

'options' => [
  ['value' => 'elk', 'text' => 'Elk', 'data-foo' => 'bar'],
]

这种形式 **要求** 定义 value 和 text 键。如果任一未设置,则不会正确生成选项。

参数
array<string, mixed> $data

用于生成复选框集的数据。

Cake\View\Form\ContextInterface $context

当前表单上下文。

返回值
string

secureFields() ¶ public

secureFields(array<string, mixed> $data): list<string>

返回此小部件需要安全保护的字段列表。

参数
array<string, mixed> $data
返回值
list<string>

setMaxLength() ¶ protected

setMaxLength(array<string, mixed> $data, Cake\View\Form\ContextInterface $context, string $fieldName): array<string, mixed>

如果适用,设置 "maxlength" 属性的值。

参数
array<string, mixed> $data

数据数组

Cake\View\Form\ContextInterface $context

上下文实例。

string $fieldName

字段名称。

返回值
array<string, mixed>

setRequired() ¶ protected

setRequired(array<string, mixed> $data, Cake\View\Form\ContextInterface $context, string $fieldName): array<string, mixed>

如果适用,设置 "required" 属性的值。

参数
array<string, mixed> $data

数据数组

Cake\View\Form\ContextInterface $context

上下文实例。

string $fieldName

字段名称。

返回值
array<string, mixed>

setStep() ¶ protected

setStep(array<string, mixed> $data, Cake\View\Form\ContextInterface $context, string $fieldName): array<string, mixed>

如果适用,设置 "step" 属性的值。

参数
array<string, mixed> $data

数据数组

Cake\View\Form\ContextInterface $context

上下文实例。

string $fieldName

字段名称。

返回值
array<string, mixed>

属性详情

$_idPrefix ¶ protected

ID 属性的前缀。

类型
string|null

$_idSuffixes ¶ protected

当前渲染中使用的 ID 后缀列表。

类型
list<string>

$_label ¶ protected

标签小部件实例。

类型
Cake\View\Widget\LabelWidget

$_templates ¶ protected

字符串模板实例。

类型
Cake\View\StringTemplate

$defaults ¶ protected

数据默认值。

类型
array<string, mixed>
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与
  • 问题(Github)
  • 烘焙
  • 特色资源
  • 培训
  • 聚会
  • 我的CakePHP
  • CakeFest
  • 通讯
  • 领英
  • YouTube
  • 脸书
  • 推特
  • Mastodon
  • 帮助与支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成