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
    • 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

类 FormHelper

表单助手库。

从给定数据自动生成 HTML 表单。

命名空间: Cake\View\Helper
链接: https://book.cakephp.com.cn/5/en/views/helpers/form.html

常量

  • 字符串
    SECURE_SKIP ¶
    'skip'

    内部使用的常量,用于跳过安全处理,既不将字段添加到哈希中,也不添加到解锁的字段中。

属性摘要

  • $Html public @property
    Cake\View\Helper\HtmlHelper
  • $Url public @property
    Cake\View\Helper\UrlHelper
  • $_View protected
    Cake\View\View

    此助手附加到的 View 实例

  • $_config protected
    array<string, mixed>

    运行时配置

  • $_configInitialized protected
    bool

    配置属性是否已使用默认值进行配置

  • $_context protected
    Cake\View\Form\ContextInterface|null

    当前表单的上下文。

  • $_contextFactory protected
    Cake\View\Form\ContextFactory|null

    上下文工厂。

  • $_defaultConfig protected
    array<string, mixed>

    助手的默认配置。

  • $_defaultWidgets protected
    array<string, list<string>>

    默认小部件

  • $_groupedInputTypes protected
    list<string>

    分组输入类型。

  • $_idPrefix protected
    string|null

    id 属性的前缀。

  • $_idSuffixes protected
    list<string>

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

  • $_lastAction protected
    字符串

    最后一个创建的表单的 action 属性值。用于为表单篡改保护创建表单/请求特定的哈希。

  • $_locator protected
    Cake\View\Widget\WidgetLocator

    输入小部件的定位器。

  • $_templater protected
    Cake\View\StringTemplate|null

    StringTemplate 实例。

  • $_valueSources protected
    list<string>

    默认来源。

  • $formProtector protected
    Cake\Form\FormProtector|null

    表单保护器

  • $helperInstances protected
    array<string,Cake\View\Helper>

    已加载的助手实例。

  • $helpers protected
    数组

    FormHelper 使用的其他助手

  • $requestType public
    string|null

    定义正在创建的表单类型。由 FormHelper::create() 设置。

  • $supportedValueSources protected
    list<string>

    可用于填充输入值的受支持来源。

方法摘要

  • __call() public

    缺少方法处理程序 - 实现各种简单的输入类型。用于创建各种类型的输入。例如,$this->Form->text(); 将创建 <input type="text">,而 $this->Form->range(); 将创建 <input type="range">

  • __construct() public

    构造小部件并绑定默认上下文提供程序

  • __debugInfo() public

    返回一个可用于描述此对象内部状态的数组。

  • __get() public

    懒加载助手。

  • _clearIds() protected

    清除存储的 ID 后缀。

  • _configDelete() protected

    删除单个配置键。

  • _configRead() protected

    读取配置键。

  • _configWrite() protected

    写入配置键。

  • _confirm() protected

    返回一个字符串,用作确认对话框的 onclick 处理程序。

  • _csrfField() protected

    如果请求数据存在,则返回 CSRF 输入。用于与 CsrfMiddleware 结合使用来保护表单。

  • _domId() protected

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

  • _extractOption() protected

    从选项数组中提取单个选项。

  • _formUrl() protected

    根据选项创建表单的 URL。

  • _getContext() protected

    查找与数据匹配的上下文提供程序。

  • _getFormProtectorSessionId() protected

    获取 FormProtector 的 Session id 必须与 FormProtectionComponent 中的相同

  • _getInput() protected

    生成输入元素

  • _getLabel() protected

    为输入生成标签

  • _groupTemplate() protected

    生成组模板元素

  • _id() protected

    为元素生成 ID 属性。

  • _idSuffix() protected

    生成 ID 后缀。

  • _initInputField() protected

    设置字段默认值并将字段添加到表单安全输入哈希中。如果字段包含验证错误,还将添加错误类。

  • _inputContainerTemplate() protected

    生成输入容器模板

  • _inputLabel() protected

    为 input() 调用生成标签。

  • _inputType() protected

    返回为提供的 fieldName 推测的输入类型,基于它关联的内部类型、它的名称以及可以在视图模板中找到的变量

  • _isDisabled() protected

    确定字段是否被禁用。

  • _lastAction() protected

    正确存储最后一个创建的表单操作 URL。

  • _magicOptions() protected

    神奇地设置选项类型和相应的选项

  • _optionsOptions() protected

    如果存在,则选择包含选择字段选项的变量,并将值设置为选项数组中的 'options' 键。

  • _parseOptions() protected

    生成输入选项数组

  • addClass() public

    将给定的类添加到元素选项中

  • addContextProvider() public

    添加新的上下文类型。

  • addWidget() public

    向 FormHelper 添加新的小部件。

  • allControls() public

    为 $fields 生成一组控件。如果 $fields 为空,将使用当前模型的字段。

  • button() public

    创建 <button> 标签。

  • checkbox() public

    创建复选框输入小部件。

  • configShallow() public

    将提供的配置与现有配置合并。与 config() 对嵌套键进行递归合并不同,此方法执行简单合并。

  • context() public

    获取当前表单集的上下文实例。

  • contextFactory() public

    设置助手将使用的上下文工厂。

  • control() public

    生成一个表单控件元素,包括标签和包装 div。

  • controls() public

    在 fieldset 元素中生成一组针对 $fields 的控件。

  • create() public

    返回一个 HTML 表单元素。

  • createFormProtector() protected

    创建 FormProtector 实例。

  • date() public

    生成一个类型为“date”的 input 标签。

  • dateTime() public

    生成一个类型为“datetime-local”的 input 标签。

  • day() public @method

    创建类型为 day 的 input。

  • email() public @method

    创建类型为 email 的 input。

  • end() public

    关闭 HTML 表单,清理 FormHelper::create() 设置的值,并在必要时写入隐藏的 input 字段。

  • enumOptions() protected

    获取用于 select/radio 选项的枚举值 => 标签映射。

  • error() public

    返回给定表单字段的格式化错误消息,如果没有错误则返回 ''。

  • fieldset() public

    将一组输入包装在 fieldset 中

  • file() public

    创建文件 input 小部件。

  • formatTemplate() public

    使用 $data 格式化模板字符串

  • getConfig() public

    返回配置。

  • getConfigOrFail() public

    返回此特定键的配置。

  • getFormProtector() public

    获取表单保护器实例。

  • getSourceValue() public

    从可用来源获取单个字段值。

  • getTemplates() public

    获取要使用的模板或特定模板。

  • getValueSources() public

    获取值来源。

  • getView() public

    获取此辅助函数绑定到的视图实例。

  • getWidgetLocator() public

    获取辅助函数当前使用的 widget 定位器。

  • hidden() public

    创建隐藏的 input 字段。

  • hour() public @method

    创建类型为 hour 的 input。

  • implementedEvents() public

    事件监听器。

  • initialize() public

    构造函数钩子方法。

  • isFieldError() public

    如果给定字段存在错误,则返回 true,否则返回 false

  • label() public

    返回 HTML 表单的格式化 LABEL 元素。

  • meridian() public @method

    创建类型为 meridian 的 input。

  • minute() public @method

    创建类型为 minute 的 input。

  • month() public

    生成一个类型为“month”的 input 标签。

  • multiCheckbox() public

    从选项创建一组复选框。

  • number() public @method

    创建类型为 number 的 input。

  • password() public @method

    创建类型为 password 的 input。

  • postButton() public

    创建一个 <button> 标签,周围有一个 <form>,默认情况下通过 POST 提交。

  • postLink() public

    创建一个 HTML 链接,但使用您指定的 method 访问 URL(默认为 POST)。要求浏览器启用 javascript。

  • radio() public

    创建一组单选按钮小部件。

  • resetTemplates() public

    恢复 FormHelper 中内置的默认值。

  • search() public @method

    创建类型为 search 的 input。

  • secure() public

    生成一个隐藏字段,其中包含基于表单中使用的字段的安全哈希。

  • select() public

    返回格式化的 SELECT 元素。

  • setConfig() public

    设置配置。

  • setRequiredAndCustomValidity() protected

    设置 required 属性和自定义验证 JS。

  • setTemplates() public

    设置要使用的模板。

  • setValueSources() public

    设置值来源。

  • setWidgetLocator() public

    设置辅助函数将使用的 widget 定位器。

  • submit() public

    创建提交按钮元素。此方法将生成可用于提交和重置表单的 <input> 元素,方法是使用 $options。可以通过为 $caption 提供图像路径来创建图像提交。

  • templater() public

    返回模板器实例。

  • text() public @method

    创建类型为 text 的 input。

  • textarea() public

    创建一个 textarea 小部件。

  • time() public

    生成一个类型为“time”的 input 标签。

  • unlockField() public

    添加到当前解锁的字段列表中。

  • validateValueSources() protected

    验证值来源。

  • widget() public

    渲染命名的小部件。

  • year() public

    返回用于年份的 SELECT 元素

方法详情

__call() ¶ public

__call(string $method, array $params): string

缺少方法处理程序 - 实现各种简单的输入类型。用于创建各种类型的输入。例如,$this->Form->text(); 将创建 <input type="text">,而 $this->Form->range(); 将创建 <input type="range">

用法

$this->Form->search('User.query', ['value' => 'test']);

将生成类似于以下内容的 input:

<input type="search" id="UserQuery" name="User[query]" value="test">

input 类型的第一个参数应始终为字段名,格式为 Model.field。第二个参数应始终为 input 的属性数组。

参数
string $method

要创建的方法名/input 类型。

array $params

方法调用的参数

返回值
字符串
抛出
Cake\Core\Exception\CakeException
当方法调用没有参数时。

__construct() ¶ public

__construct(Cake\View\View $view, array<string, mixed> $config = [])

构造小部件并绑定默认上下文提供程序

参数
Cake\View\View $view

此辅助函数附加到的视图。

array<string, mixed> $config optional

辅助函数的配置设置。

__debugInfo() ¶ public

__debugInfo(): array<string, mixed>

返回一个可用于描述此对象内部状态的数组。

返回值
array<string, mixed>

__get() ¶ public

__get(string $name): Cake\View\Helper|null

懒加载助手。

参数
string $name

正在访问的属性的名称。

返回值
Cake\View\Helper|null

_clearIds() ¶ protected

_clearIds(): void

清除存储的 ID 后缀。

返回值
void

_configDelete() ¶ protected

_configDelete(string $key): void

删除单个配置键。

参数
string $key

要删除的键。

返回值
void
抛出
Cake\Core\Exception\CakeException
如果试图覆盖现有配置

_configRead() ¶ protected

_configRead(string|null $key): mixed

读取配置键。

参数
string|null $key

要读取的键。

返回值
mixed

_configWrite() ¶ protected

_configWrite(array<string, mixed>|string $key, mixed $value, string|bool $merge = false): void

写入配置键。

参数
array<string, mixed>|string $key

要写入的键。

mixed $value

要写入的值。

string|bool $merge optional

True 表示递归合并,'shallow' 表示简单合并,false 表示覆盖,默认为 false。

返回值
void
抛出
Cake\Core\Exception\CakeException
如果试图覆盖现有配置

_confirm() ¶ protected

_confirm(string $okCode, string $cancelCode): string

返回一个字符串,用作确认对话框的 onclick 处理程序。

参数
string $okCode

用户选择“确定”后要执行的代码

string $cancelCode

用户选择“取消”后要执行的代码

返回值
字符串

_csrfField() ¶ protected

_csrfField(): string

如果请求数据存在,则返回 CSRF 输入。用于与 CsrfMiddleware 结合使用来保护表单。

返回值
字符串

_domId() ¶ protected

_domId(string $value): string

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

参数
string $value

要转换为 ID 的值。

返回值
字符串

_extractOption() ¶ protected

_extractOption(string $name, array<string, mixed> $options, mixed $default = null): mixed

从选项数组中提取单个选项。

参数
string $name

要提取的选项的名称。

array<string, mixed> $options

要提取的选项数组。

mixed $default optional

默认选项值

返回值
mixed

_formUrl() ¶ protected

_formUrl(Cake\View\Form\ContextInterface $context, array<string, mixed> $options): array|string

根据选项创建表单的 URL。

参数
Cake\View\Form\ContextInterface $context

要使用的上下文对象。

array<string, mixed> $options

来自 create() 的选项数组

返回值
array|string

_getContext() ¶ protected

_getContext(array $data = []): Cake\View\Form\ContextInterface

查找与数据匹配的上下文提供程序。

如果无法匹配类型,则将返回 NullContext。

参数
array $data optional

获取上下文提供者的数据。

返回值
Cake\View\Form\ContextInterface
抛出
RuntimeException
当上下文类没有实现 ContextInterface 时。

_getFormProtectorSessionId() ¶ protected

_getFormProtectorSessionId(): string

获取 FormProtector 的 Session id 必须与 FormProtectionComponent 中的相同

返回值
字符串

_getInput() ¶ protected

_getInput(string $fieldName, array<string, mixed> $options): array|string

生成输入元素

参数
string $fieldName

字段名

array<string, mixed> $options

输入元素的选项

返回值
array|string

_getLabel() ¶ protected

_getLabel(string $fieldName, array<string, mixed> $options): string|false

为输入生成标签

参数
string $fieldName

要为其生成标签的字段名称。

array<string, mixed> $options

选项列表。

返回值
string|false

_groupTemplate() ¶ protected

_groupTemplate(array<string, mixed> $options): string

生成组模板元素

参数
array<string, mixed> $options

组模板的选项

返回值
字符串

_id() ¶ protected

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

为元素生成 ID 属性。

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

参数
string $name

ID 属性名称。

string $val

ID 属性值。

返回值
字符串

_idSuffix() ¶ protected

_idSuffix(string $val): string

生成 ID 后缀。

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

参数
string $val

ID 属性值。

返回值
字符串

_initInputField() ¶ protected

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

设置字段默认值并将字段添加到表单安全输入哈希中。如果字段包含验证错误,还将添加错误类。

选项

  • secure - boolean - 字段是否应该添加到安全字段中。使用disabled选项禁用字段,也将省略该字段成为散列密钥的一部分。
  • default - mixed - 如果表单上下文中没有值,要使用的值。
  • disabled - mixed - 布尔值表示禁用状态,或者数字索引值中的字符串。
  • id - mixed - 如果为true,它将根据字段名称自动生成。

此方法会将数字索引的“disabled”转换为关联数组值。FormHelper 的内部组件需要关联选项。

此函数的输出是更完整的输入属性集,可以传递给表单小部件以生成实际的输入。

参数
string $field

要为其初始化选项的字段名称。

array<string, mixed> $options optional

要追加选项的选项数组。

返回值
array<string, mixed>

_inputContainerTemplate() ¶ protected

_inputContainerTemplate(array<string, mixed> $options): string

生成输入容器模板

参数
array<string, mixed> $options

输入容器模板的选项

返回值
字符串

_inputLabel() ¶ protected

_inputLabel(string $fieldName, array<string, mixed>|string|null $label = null, array<string, mixed> $options = []): string

为 input() 调用生成标签。

$options 可以包含 ID 覆盖的哈希。如果存在,这些覆盖将用于代替生成的价值。

参数
string $fieldName

要为其生成标签的字段名称。

array<string, mixed>|string|null $label optional

标签文本或带有标签属性的数组。

array<string, mixed> $options optional

标签元素的选项。

返回值
字符串

_inputType() ¶ protected

_inputType(string $fieldName, array<string, mixed> $options): string

返回为提供的 fieldName 推测的输入类型,基于它关联的内部类型、它的名称以及可以在视图模板中找到的变量

参数
string $fieldName

要猜测类型的字段名称

array<string, mixed> $options

传递给 input 方法的选项

返回值
字符串

_isDisabled() ¶ protected

_isDisabled(array<string, mixed> $options): bool

确定字段是否被禁用。

参数
array<string, mixed> $options

选项集。

返回值
bool

_lastAction() ¶ protected

_lastAction(array|string|null $url = null): void

正确存储最后一个创建的表单操作 URL。

参数
array|string|null $url optional

最后一个表单的 URL。

返回值
void

_magicOptions() ¶ protected

_magicOptions(string $fieldName, array<string, mixed> $options, bool $allowOverride): array<string, mixed>

神奇地设置选项类型和相应的选项

参数
string $fieldName

要为其生成选项的字段名称。

array<string, mixed> $options

选项列表。

bool $allowOverride

此方法是否允许覆盖选项中的“type”键。

返回值
array<string, mixed>

_optionsOptions() ¶ protected

_optionsOptions(string $fieldName, array<string, mixed> $options): array<string, mixed>

如果存在,则选择包含选择字段选项的变量,并将值设置为选项数组中的 'options' 键。

参数
string $fieldName

要为其查找选项的字段名称。

array<string, mixed> $options

选项列表。

返回值
array<string, mixed>

_parseOptions() ¶ protected

_parseOptions(string $fieldName, array<string, mixed> $options): array<string, mixed>

生成输入选项数组

参数
string $fieldName

要为其解析选项的字段名称。

array<string, mixed> $options

选项列表。

返回值
array<string, mixed>

addClass() ¶ public

addClass(array<string, mixed> $options, string $class, string $key = 'class'): array<string, mixed>

将给定的类添加到元素选项中

参数
array<string, mixed> $options

要添加类别的数组选项/属性

string $class

要添加的类名。

string $key optional

要用于类的键。默认为'class'。

返回值
array<string, mixed>

addContextProvider() ¶ public

addContextProvider(string $type, callable $check): void

添加新的上下文类型。

表单上下文类型允许 FormHelper 与来自 CakePHP 外部的提供程序交互。例如,如果您想使用像 Doctrine 这样的替代 ORM,您可以创建并连接一个新的上下文类,以允许 FormHelper 从 Doctrine 读取元数据。

参数
string $type

上下文的类型。此键可用于覆盖现有提供程序。

callable $check

当表单上下文是正确类型时返回对象的调用函数。

返回值
void

addWidget() ¶ public

addWidget(string $name, Cake\View\Widget\WidgetInterface|array|string $spec): void

向 FormHelper 添加新的小部件。

允许您使用自定义代码添加或替换小部件实例。

参数
string $name

小部件的名称。例如“text”。

Cake\View\Widget\WidgetInterface|array|string $spec

字符串类名或实现 WidgetInterface 的对象。

返回值
void

allControls() ¶ public

allControls(array $fields = [], array<string, mixed> $options = []): string

为 $fields 生成一组控件。如果 $fields 为空,将使用当前模型的字段。

您可以通过$fields自定义单个控件。

$this->Form->allControls([
  'name' => ['label' => 'custom label']
]);

您可以通过将字段指定为false来排除字段

$this->Form->allControls(['title' => false]);

在上面的示例中,不会为 title 字段生成任何字段。

参数
array $fields optional

将要生成的字段的自定义数组。此数组允许您设置自定义类型、标签或其他选项。

array<string, mixed> $options optional

选项数组。有效键为

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#generating-entire-forms

button() ¶ public

button(string $title, array<string, mixed> $options = []): string

创建 <button> 标签。

选项

  • type - 按钮的“type”属性的值。默认为“submit”。
  • escapeTitle - 对按钮的标题进行 HTML 实体编码。默认为 true。
  • escape - 对按钮标签的属性进行 HTML 实体编码。默认为 true。
  • confirm - 要显示的确认消息。只有在确认后才会继续执行表单。
参数
string $title

按钮的标题。不会自动进行 HTML 编码

array<string, mixed> $options optional

选项和 HTML 属性的数组。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-button-elements

checkbox() ¶ public

checkbox(string $fieldName, array<string, mixed> $options = []): array<string, string>|string

创建复选框输入小部件。

选项

  • value - 复选框的值
  • checked - 布尔值表示此复选框已选中。
  • hiddenField - boolean|string。设置为 false 以禁用生成隐藏输入。传递字符串将定义隐藏输入的值。
  • disabled - 创建一个禁用的输入。
  • default - 为复选框设置默认值。这允许您开始将复选框选中,而无需检查 POST 数据。匹配的 POST 数据值将覆盖默认值。
参数
string $fieldName

字段的名称,例如“modelname.fieldname”

array<string, mixed> $options optional

HTML 属性的数组。

返回值
array<string, string>|string
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-checkboxes

configShallow() ¶ public

configShallow(array<string, mixed>|string $key, mixed|null $value = null): $this

将提供的配置与现有配置合并。与 config() 对嵌套键进行递归合并不同,此方法执行简单合并。

设置特定值

$this->configShallow('key', $value);

设置嵌套值

$this->configShallow('some.nested.key', $value);

同时更新多个配置设置

$this->configShallow(['one' => 'value', 'another' => 'value']);
参数
array<string, mixed>|string $key

要设置的键,或完整的配置数组。

mixed|null $value optional

要设置的值。

返回值
$this

context() ¶ public

context(Cake\View\Form\ContextInterface|null $context = null): Cake\View\Form\ContextInterface

获取当前表单集的上下文实例。

如果没有活动的表单,将返回 null。

参数
Cake\View\Form\ContextInterface|null $context 可选

设置时为新上下文,获取时为 null。

返回值
Cake\View\Form\ContextInterface

contextFactory() ¶ public

contextFactory(Cake\View\Form\ContextFactory|null $instance = null, array $contexts = []): Cake\View\Form\ContextFactory

设置助手将使用的上下文工厂。

参数
Cake\View\Form\ContextFactory|null $instance 可选

要设置的上下文工厂实例。

array $contexts 可选

上下文提供者的数组。

返回值
Cake\View\Form\ContextFactory

control() ¶ public

control(string $fieldName, array<string, mixed> $options = []): string

生成一个表单控件元素,包括标签和包装 div。

选项

有关更多信息,请参阅每个字段类型方法。对于不同 **类型** 方法的 $attributes 或 $options 中的任何选项,都可以包含在 control() 的 $options 中。此外,任何不在下面列表中或不在所选类型的选项中的未知键都将被视为生成的输入的常规 HTML 属性。

  • type - 强制您想要的部件类型,例如 type => 'select'
  • label - 字符串标签或标签选项数组。请参阅 FormHelper::label()。
  • options - 对于需要选项的小部件,例如单选按钮、下拉菜单。
  • error - 控制产生的错误消息。设置为 false 以禁用任何形式的错误报告(字段错误和错误消息)。
  • empty - 字符串或布尔值,以启用空的 select 框选项。
  • nestedInput - 与复选框和单选按钮输入一起使用。设置为 false 以将输入渲染在标签元素之外。可以将任何输入设置为 true 以强制输入在标签内。如果您为单选按钮启用此选项,您还需要修改默认的 radioWrapper 模板。
  • templates - 您想要用于此输入的模板。任何模板都将合并到已加载的模板之上。此选项可以是 /config 中包含要加载的模板的文件名,也可以是模板数组。
  • labelOptions - false 以禁用嵌套小部件(例如单选按钮、多选框)周围的标签,或者标签标签的属性数组。selected 将添加到任何类,例如 class => 'myclass',其中小部件已选中。
参数
string $fieldName

这应该为“modelname.fieldname”。

array<string, mixed> $options optional

每种类型的输入都需要不同的选项。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-form-controls

controls() ¶ public

controls(array $fields, array<string, mixed> $options = []): string

在 fieldset 元素中生成一组针对 $fields 的控件。

您可以通过$fields自定义单个控件。

$this->Form->controls([
  'name' => ['label' => 'custom label'],
  'email'
]);
参数
array $fields

要生成的字段数组。此数组允许您设置自定义类型、标签或其他选项。

array<string, mixed> $options optional

选项数组。有效键为

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#generating-entire-forms

create() ¶ public

create(mixed $context = null, array<string, mixed> $options = []): string

返回一个 HTML 表单元素。

选项

  • type 表单方法默认为根据表单上下文自动检测。如果表单上下文的 isCreate() 方法返回 false,则将执行 PUT 请求。
  • method 显式设置表单的 method 属性。
  • url 表单提交到的 URL。可以是字符串或 URL 数组。
  • encoding 为表单设置 accept-charset 编码。默认为 Configure::read('App.encoding')
  • enctype 显式设置表单编码。默认情况下,type => file 会将 enctype 设置为 multipart/form-data。
  • templates 您想要用于此表单的模板。任何模板都将合并到已加载的模板之上。此选项可以是 /config 中包含要加载的模板的文件名,也可以是模板数组。
  • context 上下文类的其他选项。例如,EntityContext 接受一个 'table' 选项,允许您设置表单应基于的特定 Table 类。
  • idPrefix 生成的 ID 属性的前缀。
  • valueSources 应从中读取值的源。请参阅 FormHelper::setValueSources()
  • templateVars 为 formStart 模板提供模板变量。
参数
mixed $context 可选

定义表单的上下文。可以是 ContextInterface 实例、ORM 实体、ORM 结果集或元数据数组。您可以使用 null 来创建无上下文的表单。

array<string, mixed> $options optional

HTML 属性和选项数组。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#Cake\View\Helper\FormHelper::create

createFormProtector() ¶ protected

createFormProtector(array<string, mixed> $formTokenData): Cake\Form\FormProtector

创建 FormProtector 实例。

参数
array<string, mixed> $formTokenData

令牌数据。

返回值
Cake\Form\FormProtector

date() ¶ public

date(string $fieldName, array<string, mixed> $options = []): string

生成一个类型为“date”的 input 标签。

选项

请参阅 dateTime() 选项。

参数
string $fieldName

字段名称。

array<string, mixed> $options optional

选项或 HTML 属性数组。

返回值
字符串

dateTime() ¶ public

dateTime(string $fieldName, array<string, mixed> $options = []): string

生成一个类型为“datetime-local”的 input 标签。

选项

  • value | default 输入使用的默认值。如果设置为 true,则将使用当前日期时间。
参数
string $fieldName

字段名称。

array<string, mixed> $options optional

选项或 HTML 属性数组。

返回值
字符串

day() ¶ public @method

day(string $fieldName, array $options = []): string

创建类型为 day 的 input。

参数
string $fieldName
array $options 可选
返回值
字符串

email() ¶ public @method

email(string $fieldName, array $options = []): string

创建类型为 email 的 input。

参数
string $fieldName
array $options 可选
返回值
字符串

end() ¶ public

end(array<string, mixed> $secureAttributes = []): string

关闭 HTML 表单,清理 FormHelper::create() 设置的值,并在必要时写入隐藏的 input 字段。

将多个 FormHelper::create() 调用之间共享的某些状态部分重置为默认值。

参数
array<string, mixed> $secureAttributes 可选

安全属性,将作为 HTML 属性传递给为 Security Component 生成的隐藏输入元素。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#closing-the-form

enumOptions() ¶ protected

enumOptions(class-stringBackedEnum> $enumClass): array<int|string, string>

获取用于 select/radio 选项的枚举值 => 标签映射。

参数
class-stringBackedEnum> $enumClass

枚举类名称。

返回值
array<int|string, string>

error() ¶ public

error(string $field, array|string|null $text = null, array<string, mixed> $options = []): string

返回给定表单字段的格式化错误消息,如果没有错误则返回 ''。

使用 error、errorList 和 errorItem 模板。errorList 和 errorItem 模板用于格式化每个字段的多个错误消息。

选项

  • escape 布尔值 - 是否对错误内容进行 HTML 转义。
参数
string $field

字段名称,如“modelname.fieldname”。

array|string|null $text 可选

错误消息作为字符串或消息数组。如果为数组,则应为键名称 => 消息的哈希。

array<string, mixed> $options optional

见上文。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#displaying-and-checking-errors

fieldset() ¶ public

fieldset(string $fields = '', array<string, mixed> $options = []): string

将一组输入包装在 fieldset 中

参数
string $fields 可选

要包装在 fieldset 中的表单输入

array<string, mixed> $options optional

选项数组。有效键为

返回值
字符串

file() ¶ public

file(string $fieldName, array<string, mixed> $options = []): string

创建文件 input 小部件。

参数
string $fieldName

字段名称,格式为“modelname.fieldname”。

array<string, mixed> $options optional

HTML 属性的数组。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-file-inputs

formatTemplate() ¶ public

formatTemplate(string $name, array<string, mixed> $data): string

使用 $data 格式化模板字符串

参数
string $name

模板名称。

array<string, mixed> $data

要插入的数据。

返回值
字符串

getConfig() ¶ public

getConfig(string|null $key = null, mixed $default = null): mixed

返回配置。

用法

读取整个配置

$this->getConfig();

读取特定值

$this->getConfig('key');

读取嵌套值

$this->getConfig('some.nested.key');

读取带有默认值的

$this->getConfig('some-key', 'default-value');
参数
string|null $key 可选

要获取的键,或整个配置的 null。

mixed $default optional

键不存在时的返回值。

返回值
mixed

getConfigOrFail() ¶ public

getConfigOrFail(string $key): mixed

返回此特定键的配置。

此键的配置值必须存在,不能为 null。

参数
string $key

要获取的键。

返回值
mixed
抛出
InvalidArgumentException

getFormProtector() ¶ public

getFormProtector(): Cake\Form\FormProtector|null

获取表单保护器实例。

返回值
Cake\Form\FormProtector|null

getSourceValue() ¶ public

getSourceValue(string $fieldname, array<string, mixed> $options = []): mixed

从可用来源获取单个字段值。

参数
string $fieldname

要获取值的字段名称。

array<string, mixed> $options optional

包含默认值的选项。

返回值
mixed

getTemplates() ¶ public

getTemplates(string|null $template = null): array|string

获取要使用的模板或特定模板。

参数
string|null $template 可选

用于读取特定模板的字符串,null 表示所有模板。

返回值
array|string

getValueSources() ¶ public

getValueSources(): list<string>

获取值来源。

返回一个包含至少一项的有效源列表,例如:'context'、'data' 和 'query'。

返回值
list<string>

getView() ¶ public

getView(): Cake\View\View

获取此辅助函数绑定到的视图实例。

返回值
Cake\View\View

getWidgetLocator() ¶ public

getWidgetLocator(): Cake\View\Widget\WidgetLocator

获取辅助函数当前使用的 widget 定位器。

返回值
Cake\View\Widget\WidgetLocator

hidden() ¶ public

hidden(string $fieldName, array<string, mixed> $options = []): string

创建隐藏的 input 字段。

参数
string $fieldName

字段名称,格式为 "modelname.fieldname"

array<string, mixed> $options optional

HTML 属性的数组。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-hidden-inputs

hour() ¶ public @method

hour(string $fieldName, array $options = []): string

创建类型为 hour 的 input。

参数
string $fieldName
array $options 可选
返回值
字符串

implementedEvents() ¶ public

implementedEvents(): array<string, mixed>

事件监听器。

通过定义回调方法之一,助手程序被认为对相关事件感兴趣。

如果您需要添加非传统事件监听器,或者您希望助手程序监听非标准事件,请覆盖此方法。

返回值
array<string, mixed>

initialize() ¶ public

initialize(array<string, mixed> $config): void

构造函数钩子方法。

实现此方法以避免覆盖构造函数并调用父类。

参数
array<string, mixed> $config

提供给此助手程序的配置设置。

返回值
void

isFieldError() ¶ public

isFieldError(string $field): bool

如果给定字段存在错误,则返回 true,否则返回 false

参数
string $field

这应该为“modelname.fieldname”。

返回值
bool
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#displaying-and-checking-errors

label() ¶ public

label(string $fieldName, string|null $text = null, array<string, mixed> $options = []): string

返回 HTML 表单的格式化 LABEL 元素。

如果未提供 for 属性,则会自动生成 for 属性。

选项

  • for - 设置 for 属性,如果未定义,for 属性将使用 FormHelper::_domId() 从 $fieldName 参数生成。
  • escape - 设置为 false 以关闭标签文本的转义。默认为 true。

示例

文本和 for 属性根据字段名称生成

echo $this->Form->label('published');
<label for="PostPublished">Published</label>

自定义文本

echo $this->Form->label('published', 'Publish');
<label for="published">Publish</label>

自定义属性

echo $this->Form->label('published', 'Publish', [
  'for' => 'post-publish'
]);
<label for="post-publish">Publish</label>

嵌套输入标签

echo $this->Form->label('published', 'Publish', [
  'for' => 'published',
  'input' => $this->text('published'),
]);
<label for="post-publish">Publish <input type="text" name="published"></label>

如果您想在标签中嵌套输入,则需要修改默认模板。

参数
string $fieldName

这应该为“modelname.fieldname”。

string|null $text optional

将出现在标签字段中的文本。如果未定义 $text,文本将从 fieldName 中推断出来。

array<string, mixed> $options optional

HTML 属性数组。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-labels

meridian() ¶ public @method

meridian(string $fieldName, array $options = []): string

创建类型为 meridian 的 input。

参数
string $fieldName
array $options 可选
返回值
字符串

minute() ¶ public @method

minute(string $fieldName, array $options = []): string

创建类型为 minute 的 input。

参数
string $fieldName
array $options 可选
返回值
字符串

month() ¶ public

month(string $fieldName, array<string, mixed> $options = []): string

生成一个类型为“month”的 input 标签。

选项

请参阅 dateTime() 选项。

参数
string $fieldName

字段名称。

array<string, mixed> $options optional

选项或 HTML 属性数组。

返回值
字符串

multiCheckbox() ¶ public

multiCheckbox(string $fieldName, iterable $options, array<string, mixed> $attributes = []): string

从选项创建一组复选框。

选项

  • escape - 如果为 true,则选项内容将进行 HTML 实体编码。默认为 true。
  • val 输入的选择值。
  • class - 当使用 multiple = checkbox 时,要应用于 div 的类名。默认为 'checkbox'。
  • disabled - 控制禁用属性。当创建复选框时,true 将禁用所有复选框。您还可以将 disabled 设置为要在创建复选框时禁用的值列表。
  • hiddenField - 设置为 false 以删除确保始终提交值的隐藏字段。
  • label - 为 false 以禁用小部件周围的标签,或为标签标签提供属性数组。例如 'class' => 'myclass',当小部件被选中时会添加 selected。

可以代替具有 multiple 属性的选择框使用。

参数
string $fieldName

SELECT 的名称属性

iterable $options

将用在复选框元素中的 OPTION 元素数组(作为 'value'=>'Text' 对)。

array<string, mixed> $attributes optional

选择元素的 HTML 属性。

返回值
字符串
另请参阅
\Cake\View\Helper\FormHelper::select(),了解支持的选项格式。

number() ¶ public @method

number(string $fieldName, array $options = []): string

创建类型为 number 的 input。

参数
string $fieldName
array $options 可选
返回值
字符串

password() ¶ public @method

password(string $fieldName, array $options = []): string

创建类型为 password 的 input。

参数
string $fieldName
array $options 可选
返回值
字符串

postButton() ¶ public

postButton(string $title, array|string $url, array<string, mixed> $options = []): string

创建一个 <button> 标签,周围有一个 <form>,默认情况下通过 POST 提交。

此方法创建一个 <form> 元素。因此,不要在已打开的表单中使用此方法。而是使用 FormHelper::submit() 或 FormHelper::button() 在打开的表单中创建按钮。

选项

  • data - 包含要传递给隐藏输入的键值对的数组
  • method - 要使用的请求方法。设置为 'delete' 或其他值以模拟 HTTP/1.1 DELETE(或其他)请求。默认为 'post'。
  • form - 包含 FormHelper::create() 可以接受的任何选项的数组
  • 其他选项与 button 方法相同。
  • confirm - 要显示的确认消息。只有在确认后才会继续执行表单。
参数
string $title

按钮的标题。不会自动进行 HTML 编码

array|string $url

URL 作为字符串或数组

array<string, mixed> $options optional

选项和 HTML 属性的数组。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-standalone-buttons-and-post-links

postLink() ¶ public

postLink(string $title, array|string|null $url = null, array<string, mixed> $options = []): string

创建一个 HTML 链接,但使用您指定的 method 访问 URL(默认为 POST)。要求浏览器启用 javascript。

此方法创建一个 <form> 元素。如果您想在现有表单中使用此方法,则必须使用 block 选项,以便将新表单设置为可以渲染在主表单之外的视图块。

如果您要寻找的是一个提交表单的按钮,那么您应该改用 FormHelper::button() 或 FormHelper::submit()。

选项

  • data - 包含要传递给隐藏输入的键值对的数组
  • method - 要使用的请求方法。设置为 'delete' 以模拟 HTTP/1.1 DELETE 请求。默认为 'post'。
  • confirm - 要显示的确认消息。只有在确认后才会继续执行表单。
  • block - 设置为 true 以将表单附加到视图块 "postLink" 或提供自定义块名称。
  • 其他选项与 HtmlHelper::link() 方法相同。
  • 选项 onclick 将被替换。
参数
string $title

将被 <a> 标签包围的内容。

array|string|null $url optional

Cake 相对 URL 或 URL 参数数组,或外部 URL(以 http:// 开头)

array<string, mixed> $options optional

HTML 属性的数组。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-standalone-buttons-and-post-links

radio() ¶ public

radio(string $fieldName, iterable $options = [], array<string, mixed> $attributes = []): string

创建一组单选按钮小部件。

属性

  • value - 指示选中此单选按钮时的值。
  • label - 为 false 以禁用小部件周围的标签,或为标签标签提供属性数组。例如 'class' => 'myclass',当小部件被选中时会添加 selected。
  • hiddenField - boolean|string。设置为 false 以不包含值为 '' 的隐藏输入。也可以是字符串以设置隐藏输入的值。这对于创建非连续的单选按钮集很有用。
  • disabled - 设置为 true 或 disabled 以禁用所有单选按钮。使用值数组来禁用特定单选按钮。
  • empty - 设置为 true 以创建一个值为 '' 的输入作为第一个选项。当为 true 时,单选按钮标签将为 'empty'。将此选项设置为字符串以控制标签值。
参数
string $fieldName

字段的名称,例如“modelname.fieldname”

iterable $options optional

单选按钮选项数组。

array<string, mixed> $attributes optional

属性数组。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-radio-buttons

resetTemplates() ¶ public

resetTemplates(): void

恢复 FormHelper 中内置的默认值。

此方法不会重置自定义小部件中设置的任何模板。

返回值
void

search() ¶ public @method

search(string $fieldName, array $options = []): string

创建类型为 search 的 input。

参数
string $fieldName
array $options 可选
返回值
字符串

secure() ¶ public

secure(array $fields = [], array<string, mixed> $secureAttributes = []): string

生成一个隐藏字段,其中包含基于表单中使用的字段的安全哈希。

如果设置了 $secureAttributes,这些 HTML 属性将被合并到为安全组件生成的隐藏输入标签中。这对于设置像 'form' 这样的 HTML5 属性特别有用。

参数
array $fields optional

如果设置了,则指定要添加到 FormProtector 的字段列表,以生成哈希值。

array<string, mixed> $secureAttributes 可选

将作为 HTML 属性传递到为安全组件生成的隐藏输入元素中。

返回值
字符串

select() ¶ public

select(string $fieldName, iterable $options = [], array<string, mixed> $attributes = []): string

返回格式化的 SELECT 元素。

属性

  • multiple - 显示一个多选框。如果设置为 'checkbox',将创建多个复选框。
  • empty - 如果为 true,则显示空选项。如果为字符串,则该字符串将显示为空元素。
  • escape - 如果为 true,则选项内容将进行 HTML 实体编码。默认为 true。
  • val 输入的选择值。
  • disabled - 控制 disabled 属性。创建选择框时,设置为 true 将禁用选择框。设置为数组将禁用特定选项元素。

使用选项

一个简单的数组将创建普通的选项

$options = [1 => 'one', 2 => 'two'];
$this->Form->select('Model.field', $options));

而嵌套的选项数组将创建带有选项的选项组。

$options = [
 1 => 'bill',
    'fred' => [
        2 => 'fred',
        3 => 'fred jr.'
    ]
];
$this->Form->select('Model.field', $options);

如果您有多个选项需要具有相同的 value 属性,您可以使用数组的数组来表示这一点

$options = [
    ['text' => 'United states', 'value' => 'USA'],
    ['text' => 'USA', 'value' => 'USA'],
];
参数
string $fieldName

SELECT 的名称属性

iterable $options optional

要用于 SELECT 元素的 OPTION 元素数组(作为 'value'=>'Text' 对)。

array<string, mixed> $attributes optional

选择元素的 HTML 属性。

返回值
字符串
另请参阅
\Cake\View\Helper\FormHelper::multiCheckbox() 用于创建多个复选框。
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-select-pickers

setConfig() ¶ public

setConfig(array<string, mixed>|string $key, mixed|null $value = null, bool $merge = true): $this

设置配置。

用法

设置特定值

$this->setConfig('key', $value);

设置嵌套值

$this->setConfig('some.nested.key', $value);

同时更新多个配置设置

$this->setConfig(['one' => 'value', 'another' => 'value']);
参数
array<string, mixed>|string $key

要设置的键,或完整的配置数组。

mixed|null $value optional

要设置的值。

bool $merge optional

是否递归合并或覆盖现有配置,默认为 true。

返回值
$this
抛出
Cake\Core\Exception\CakeException
尝试设置一个无效的键时。

setRequiredAndCustomValidity() ¶ protected

setRequiredAndCustomValidity(string $fieldName, array<string, mixed> $options): array<string, mixed>

设置 required 属性和自定义验证 JS。

参数
string $fieldName

要为其生成选项的字段名称。

array<string, mixed> $options

选项列表。

返回值
array<string, mixed>

setTemplates() ¶ public

setTemplates(array<string, string> $templates): $this

设置要使用的模板。

参数
array<string, string> $templates

要添加的模板。

返回值
$this

setValueSources() ¶ public

setValueSources(list<string>|string $sources): $this

设置值来源。

您需要提供一个或多个有效的源,作为字符串列表。顺序设置优先级。

参数
list<string>|string $sources

标识源的字符串或字符串列表。

返回值
$this
抛出
InvalidArgumentException
如果源列表包含无效值。
另请参阅
FormHelper::$supportedValueSources 用于有效值。

setWidgetLocator() ¶ public

setWidgetLocator(Cake\View\Widget\WidgetLocator $instance): $this

设置辅助函数将使用的 widget 定位器。

参数
Cake\View\Widget\WidgetLocator $instance

要设置的定位器实例。

返回值
$this

submit() ¶ public

submit(string|null $caption = null, array<string, mixed> $options = []): string

创建提交按钮元素。此方法将生成可用于提交和重置表单的 <input> 元素,方法是使用 $options。可以通过为 $caption 提供图像路径来创建图像提交。

选项

  • type - 设置为 'reset' 用于重置输入。默认为 'submit'
  • templateVars - 输入元素及其容器的附加模板变量。
  • 其他属性将分配给输入元素。
参数
string|null $caption optional

显示在按钮上的标签 OR 如果字符串包含:// 或扩展名 .jpg、.jpe、.jpeg、.gif、.png,则使用图像(如果扩展名存在),AND 第一个字符为 /,图像相对于 webroot,OR 如果第一个字符不为 /,图像相对于 webroot/img。

array<string, mixed> $options optional

选项数组。见上文。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-buttons-and-submit-elements

templater() ¶ public

templater(): Cake\View\StringTemplate

返回模板器实例。

返回值
Cake\View\StringTemplate

text() ¶ public @method

text(string $fieldName, array $options = []): string

创建类型为 text 的 input。

参数
string $fieldName
array $options 可选
返回值
字符串

textarea() ¶ public

textarea(string $fieldName, array<string, mixed> $options = []): string

创建一个 textarea 小部件。

选项

  • escape - 文本区域的内容是否应该转义。默认为 true。
参数
string $fieldName

字段名称,格式为“modelname.fieldname”。

array<string, mixed> $options optional

HTML 属性数组,以及上面的特殊选项。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-textareas

time() ¶ public

time(string $fieldName, array<string, mixed> $options = []): string

生成一个类型为“time”的 input 标签。

选项

请参阅 dateTime() 选项。

参数
string $fieldName

字段名称。

array<string, mixed> $options optional

选项或 HTML 属性数组。

返回值
字符串

unlockField() ¶ public

unlockField(string $name): $this

添加到当前解锁的字段列表中。

已解锁的字段不包含在表单保护字段哈希中。如果控制器中未加载 FormProtectionComponent,则将执行无操作。

参数
string $name

字段的点分隔名称。

返回值
$this

validateValueSources() ¶ protected

validateValueSources(list<string> $sources): void

验证值来源。

参数
list<string> $sources

标识源的字符串列表。

返回值
void
抛出
InvalidArgumentException
如果源列表包含无效值。

widget() ¶ public

widget(string $name, array $data = []): string

渲染命名的小部件。

这是一个较低级别的函数。对于内置的小部件,您应该使用像 text、hidden 和 radio 这样的函数。如果您使用其他小部件,您应该使用此函数在没有标签或包装 div 的情况下渲染小部件。

参数
string $name

小部件的名称。例如“text”。

array $data optional

要渲染的数据。

返回值
字符串

year() ¶ public

year(string $fieldName, array<string, mixed> $options = []): string

返回用于年份的 SELECT 元素

属性

  • empty - 如果为 true,则显示空选项。如果为字符串,则该字符串将显示为空元素。
  • order - 选择选项中年份值的排序。可能的值 'asc'、'desc'。默认 'desc'
  • value 输入的选定值。
  • max 选择元素中要显示的最大年份。
  • min 选择元素中要显示的最小年份。
参数
string $fieldName

字段名称。

array<string, mixed> $options optional

选择元素的选项和属性。

返回值
字符串
链接
https://book.cakephp.com.cn/5/en/views/helpers/form.html#creating-year-inputs

属性详情

$Html ¶ public @property

类型
Cake\View\Helper\HtmlHelper

$Url ¶ public @property

类型
Cake\View\Helper\UrlHelper

$_View ¶ protected

此助手附加到的 View 实例

类型
Cake\View\View

$_config ¶ protected

运行时配置

类型
array<string, mixed>

$_configInitialized ¶ protected

配置属性是否已使用默认值进行配置

类型
bool

$_context ¶ protected

当前表单的上下文。

类型
Cake\View\Form\ContextInterface|null

$_contextFactory ¶ protected

上下文工厂。

类型
Cake\View\Form\ContextFactory|null

$_defaultConfig ¶ protected

助手的默认配置。

类型
array<string, mixed>

$_defaultWidgets ¶ protected

默认小部件

类型
array<string, list<string>>

$_groupedInputTypes ¶ protected

分组输入类型。

类型
list<string>

$_idPrefix ¶ protected

id 属性的前缀。

类型
string|null

$_idSuffixes ¶ protected

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

类型
list<string>

$_lastAction ¶ protected

最后一个创建的表单的 action 属性值。用于为表单篡改保护创建表单/请求特定的哈希。

类型
字符串

$_locator ¶ protected

输入小部件的定位器。

类型
Cake\View\Widget\WidgetLocator

$_templater ¶ protected

StringTemplate 实例。

类型
Cake\View\StringTemplate|null

$_valueSources ¶ protected

默认来源。

类型
list<string>

$formProtector ¶ protected

表单保护器

类型
Cake\Form\FormProtector|null

$helperInstances ¶ protected

已加载的助手实例。

类型
array<string,Cake\View\Helper>

$helpers ¶ protected

FormHelper 使用的其他助手

类型
数组

$requestType ¶ public

定义正在创建的表单类型。由 FormHelper::create() 设置。

类型
string|null

$supportedValueSources ¶ protected

可用于填充输入值的受支持来源。

context - 对应于 ContextInterface 实例。data - 对应于请求数据 (POST/PUT)。query - 对应于请求的查询字符串。

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

使用 CakePHP API 文档 生成