CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 企业解决方案
  • 周边产品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题(Github)
    • Bakery
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻通讯
    • 领英
    • 优酷
    • 脸书
    • 推特
    • 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
    • 国际化
    • 日志
    • 邮件
    • 网络
    • ORM
    • 路由
    • 测试套件
    • 实用工具
    • 验证
    • 视图
      • 异常
      • 表单
      • 助手
      • 小部件

复选框小部件类

用于创建复选框小部件的输入小部件。

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

命名空间: Cake\View\Widget

属性概述

  • $_templates protected
    Cake\View\StringTemplate

    字符串模板实例。

  • $defaults protected
    array<string, mixed>

    数据默认值。

方法概述

  • __construct() public

    构造函数。

  • _isChecked() 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\StringTemplate $templates

模板列表。

_isChecked() ¶ protected

_isChecked(array<string, mixed> $data): bool

检查复选框是否应该被选中。

参数
array<string, mixed> $data

要查看并确定选中状态的数据。

返回
bool

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 - 输入的名称。
  • value - value 属性。默认值为 '1'。
  • val - 当前值。如果它与 value 相匹配,则复选框将被选中。您也可以使用 'checked' 属性来使复选框被选中。
  • disabled - 复选框是否应该被禁用。

传入的任何其他属性都将被视为 HTML 属性。

参数
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>

属性详细

$_templates ¶ protected

字符串模板实例。

类型
Cake\View\StringTemplate

$defaults ¶ protected

数据默认值。

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

使用 CakePHP API 文档 生成