CakePHP
  • 文档
    • 手册
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识与商标
  • 商业解决方案
  • 周边产品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与进来
    • 问题 (Github)
    • Bakery
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻稿
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • 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
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget

NullContext 类

提供一个什么都不做的上下文提供者。

此上下文提供者只是满足 FormHelper 的接口需求。

命名空间: Cake\View\Form

常量

  • list<string>
    VALID_ATTRIBUTES ¶
    ['length', 'precision', 'comment', 'null', 'default']

方法摘要

  • __construct() public

    构造函数。

  • attributes() public

    获取字段名的其他属性的关联数组。

  • error() public

    获取给定字段的错误。

  • fieldNames() public

    获取此上下文中顶级对象的字段名。

  • getMaxLength() public

    从模型验证获取字段的最大长度。

  • getPrimaryKey() public

    获取用作上下文主键的字段。

  • getRequiredMessage() public

    获取字段的默认“required”错误消息

  • hasError() public

    检查字段是否附加了错误

  • isCreate() public

    返回此表单是否用于创建操作。

  • isPrimaryKey() public

    如果传递的字段名是此上下文的主键的一部分,则返回 true

  • isRequired() public

    检查给定字段是否为“required”。

  • type() public

    获取给定字段名的抽象字段类型。

  • val() public

    获取给定字段的当前值。

方法详情

__construct() ¶ public

__construct(array $context)

构造函数。

参数
array $context

上下文信息。

attributes() ¶ public

attributes(string $field): array

获取字段名的其他属性的关联数组。

参数
string $field
返回值
array

error() ¶ public

error(string $field): array

获取给定字段的错误。

参数
string $field
返回值
array

fieldNames() ¶ public

fieldNames(): list<string>

获取此上下文中顶级对象的字段名。

返回值
list<string>

getMaxLength() ¶ public

getMaxLength(string $field): int|null

从模型验证获取字段的最大长度。

参数
string $field
返回值
int|null

getPrimaryKey() ¶ public

getPrimaryKey(): list<string>

获取用作上下文主键的字段。

返回值
list<string>

getRequiredMessage() ¶ public

getRequiredMessage(string $field): string|null

获取字段的默认“required”错误消息

参数
string $field
返回值
string|null

hasError() ¶ public

hasError(string $field): bool

检查字段是否附加了错误

参数
string $field
返回值
bool

isCreate() ¶ public

isCreate(): bool

返回此表单是否用于创建操作。

返回值
bool

isPrimaryKey() ¶ public

isPrimaryKey(string $field): bool

如果传递的字段名是此上下文的主键的一部分,则返回 true

参数
string $field
返回值
bool

isRequired() ¶ public

isRequired(string $field): bool|null

检查给定字段是否为“required”。

在此上下文类中,这仅由“required”数组定义。

参数
string $field
返回值
bool|null

type() ¶ public

type(string $field): string|null

获取给定字段名的抽象字段类型。

参数
string $field
返回值
string|null

val() ¶ public

val(string $field, array<string, mixed> $options = []): mixed

获取给定字段的当前值。

实现此方法的类可以选择具有第二个参数 $options。$options 数组的有效键是

  • default: 如果在数据或上下文记录中找不到值,则返回的默认值。
    • schemaDefault: 布尔值,指示如果未明确提供,是否应使用上下文模式中的默认值。
参数
string $field
array<string, mixed> $options optional
返回值
mixed
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 手册
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识与商标
  • 社区
  • 参与进来
  • 问题 (Github)
  • Bakery
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻稿
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助与支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成