jakesutherland / nomad-forms
WordPress PHP Composer 包,提供了一种简单的方式来显示和处理表单,渲染和验证字段,以及显示错误/成功消息。
Requires
This package is auto-updated.
Last update: 2024-09-29 06:14:30 UTC
README
WordPress PHP Composer 包,提供了一种简单的方式来显示和处理表单,渲染和验证字段,以及显示错误/成功消息。
安装
您可以通过composer在项目中安装Nomad Forms。
$ composer require jakesutherland/nomad-forms
依赖关系
Nomad Forms依赖于以下包
- Nomad Helpers 提供各种函数、常量和工具。
- Nomad Validate 用于验证表单提交并生成错误消息。
如果由于某种原因您没有通过Composer将Nomad Forms作为项目中的必需包安装,您仍然需要运行 composer install
来安装其依赖项,因为它们不包括在存储库中。
文档
Nomad Forms 是一个功能齐全的表单生成器,用于处理、验证和显示网站上的表单。您可以在前端或管理界面中使用Nomad Forms。
示例用法
使用 nomad_form()
函数来配置和设置您的表单。
第一个参数是您的表单ID。在下面的示例中,my_form_id
被用作此表单的唯一标识符。
第二个参数是您的表单参数。在这里,您可以配置表单并定义表单字段。
$my_form = nomad_form( 'my_form_id', array(
'method' => 'POST',
'callback' => 'my_form_callback',
'fields' => array(
// Add your form fields here...
),
) );
或者,如果您只想输出表单字段(同时仍然利用Nomad Forms主题样式),可以使用 nomad_fields()
函数。基本上是一个辅助函数,将各种表单参数设置为仅输出表单字段所需的内容。见下文
function nomad_fields( $id, $args ) {
$defaults = array(
'action' => null,
'method' => null,
'nonce' => true,
'form_tag' => false,
'submit_button' => false,
'reset_button' => false,
'cancel_button' => false,
'callback' => null,
);
$args = wp_parse_args( $args, $defaults );
return nomad_form( $id, $args );
}
单独使用此功能时,您需要手动处理所有表单处理和验证。
常见用法是在WordPress管理中向帖子类型添加自定义字段,然后在 save_post
中处理这些字段。
可用的表单参数
您可以使用许多不同的表单参数来自定义表单的行为。
注意:唯一的必需表单参数是 fields
。所有其他表单参数都是可选的,并已设置默认值。
action
类型: string
默认: null
设置表单操作,如果您希望表单提交到特定的URL。
不建议这样做,除非您计划自己处理表单提交。请注意,您分配给 nomad_form()
的变量仅在定义它的页面上可用,因此其他函数可能无法在其他代码库中的其他地方使用。强烈建议您在显示表单的同一页面上处理所有内容。
allow_modifications
类型: boolean
默认: true
是否允许其他插件或代码片段修改表单。
当设置为 true
时,表单可以通过各种钩子、过滤器和通过注入添加的字段进行修改。如果设置为 false
,则大多数钩子和过滤器不会触发,并且注入不会添加任何字段。
automate_validation
类型: boolean
默认: true
是否允许自动验证表单字段。
当设置为 true
时,会自动验证 "选择" 类型字段(如按钮组、复选框、单选按钮、选择框等)的值,并确保只能使用可用的选项,电子邮件字段是有效的电子邮件地址,数字字段只包含数字。
如果您已经在字段验证中指定了这些规则键,自动验证不会覆盖它们。
回调
类型: callable
默认: null
当表单成功提交时将被调用的函数。必须是一个有效的回调函数。
cancel_button
类型: boolean
默认: false
是否在表单底部显示 "取消" 按钮。
cancel_href
类型: string
默认: home_url( '/' );
(您的 WordPress 安装主页)
点击 "取消" 按钮时跳转的 URL。
cancel_text
类型: string
默认: 取消
取消按钮文本。
error_message
类型: string
默认: 抱歉,提交表单时出现问题:
当表单提交并出现错误时,此文本将显示在错误信息列表上方。
fields
类型: array
必需
要显示、提交、验证和处理的表单字段列表。
form_tag
类型: boolean
默认: true
是否应在 <form>...</form>
标签内渲染表单字段。如果设置为 false
,则表单字段将在 <div>...</div>
内渲染。
labels_alignment
类型: string
默认: left
可能的值: left
center
right
确定字段标签的文本对齐方式。
labels_position
类型: string
默认: top
可能的值: inline
top
确定字段标签相对于其字段的位置。
method
类型: string
默认: POST
可能的值: POST
GET
确定提交字段时使用的表单方法。
nonce
类型: boolean
默认: true
是否创建并使用 nomad_form_nonce
以确保正在处理的表单是刚刚提交的表单。
nonce_message
类型: string
默认: 无效的表单提交。请重试。
如果密钥验证失败且表单提交无效,将显示此文本。
reset_button
类型: boolean
默认: false
是否在表单底部显示 "重置" 按钮。
reset_text
类型: string
默认: 重置
重置按钮文本。
submit_button
类型: boolean
默认: true
是否在表单底部显示 "提交" 按钮。
submit_text
类型: string
默认: 提交
提交按钮文本。
success_message
类型: string
默认: 成功!您的表单已提交。
当表单提交并出现错误时,此文本将显示在错误信息列表上方。
可用字段
每个字段都在 Nomad_Form_Fields
类中定义为常量。以下是所有可用字段的列表及其注册示例。
或者,您可以查看 example.php 以测试包含每种可用字段类型的 Nomad 表单。
AM PM 字段
用法: Nomad_Form_Fields::AM_PM
带有 AM 和 PM 选项的选择下拉菜单。
'example_am_pm' => array(
'name' => 'example_am_pm',
'label' => 'AM PM Field',
'type' => Nomad_Form_Fields::AM_PM,
),
按钮组字段
用法: Nomad_Form_Fields::BUTTON_GROUP
样式化的单选按钮。如果提供了 multiple
参数并将其设置为 true
,则样式化按钮将像复选框一样行为。
'example_button_group' => array(
'name' => 'example_button_group',
'label' => 'Button Group Field',
'type' => Nomad_Form_Fields::BUTTON_GROUP,
'multiple' => true,
'options' => array(
'a' => 'Choice A',
'b' => 'Choice B',
'c' => 'Choice C',
),
),
复选框字段
用法: Nomad_Form_Fields::CHECKBOX
单个复选框。
'example_checkbox' => array(
'name' => 'example_checkbox',
'label' => 'Checkbox Field',
'type' => Nomad_Form_Fields::CHECKBOX,
'checkbox_text' => 'Checkbox text.',
),
复选框字段
用法: Nomad_Form_Fields::CHECKBOXES
多个复选框。
'example_checkboxes' => array(
'name' => 'example_checkboxes',
'label' => 'Checkboxes Field',
'type' => Nomad_Form_Fields::CHECKBOXES,
'options' => array(
'a' => 'Choice A is the longest option<br>it has three lines<br>how about that?',
'b' => 'Choice B is much longer<br>spans a couple lines',
'c' => 'Choice C is the shortest',
),
),
国家字段
用法: Nomad_Form_Fields::COUNTRY
带有所有国家选项的选择下拉菜单。
'example_country' => array(
'name' => 'example_country',
'label' => 'Country Field',
'type' => Nomad_Form_Fields::COUNTRY,
),
日期字段
用法: Nomad_Form_Fields::DATE
日期输入字段。
'example_date' => array(
'name' => 'example_date',
'label' => 'Date Field',
'type' => Nomad_Form_Fields::DATE,
),
日字段
用法: Nomad_Form_Fields::DAY
带有月份中天(01-31)选项的选择下拉菜单。
'example_day' => array(
'name' => 'example_day',
'label' => 'Day Field',
'type' => Nomad_Form_Fields::DAY,
),
电子邮件字段
用法:Nomad_Form_Fields::EMAIL
电子邮件输入字段。
'example_email' => array(
'name' => 'example_email',
'label' => 'Email Field',
'type' => Nomad_Form_Fields::EMAIL,
),
启用/禁用按钮组
用法:Nomad_Form_Fields::ENABLE_DISABLE_BUTTON_GROUP
具有预定义启用和禁用选项的按钮组。
'example_enable_disable_button_group' => array(
'name' => 'example_enable_disable_button_group',
'label' => 'Enable Disable Button Group',
'type' => Nomad_Form_Fields::ENABLE_DISABLE_BUTTON_GROUP,
),
启用/禁用按钮组
用法:Nomad_Form_Fields::ENABLED_DISABLED_BUTTON_GROUP
具有预定义启用和禁用选项的按钮组。
'example_enabled_disabled_button_group' => array(
'name' => 'example_enabled_disabled_button_group',
'label' => 'Enabled Disabled Button Group',
'type' => Nomad_Form_Fields::ENABLED_DISABLED_BUTTON_GROUP,
),
隐藏字段
用法:Nomad_Form_Fields::HIDDEN
隐藏输入字段。
'example_hidden' => array(
'name' => 'example_hidden',
'label' => 'Hidden Field',
'type' => Nomad_Form_Fields::HIDDEN,
'value' => 'hidden_value',
),
小时字段
用法:Nomad_Form_Fields::HOUR
选择下拉菜单,选项为一天中的小时。您可以使用format
指定12
或24
以获得1-12或0-23小时格式的选项。默认为12小时格式。
'example_hour' => array(
'name' => 'example_hour',
'label' => 'Hour Field',
'type' => Nomad_Form_Fields::HOUR,
),
分钟字段
用法:Nomad_Form_Fields::MINUTE
选择下拉菜单,选项为00-60
分钟。
'example_minute' => array(
'name' => 'example_minute',
'label' => 'Minute Field',
'type' => Nomad_Form_Fields::MINUTE,
),
月份字段
用法:Nomad_Form_Fields::MONTH
选择下拉菜单,选项为一年中的月份。您可以使用format
指定full
(一月到十二月)、short
(一月至十二月)或number
(1-12)格式的选项。默认格式:number
。
'example_month' => array(
'name' => 'example_month',
'label' => 'Month Field',
'type' => Nomad_Form_Fields::MONTH,
),
数字字段
用法:Nomad_Form_Fields::NUMBER
数字输入字段。
'example_number' => array(
'name' => 'example_number',
'label' => 'Number Field',
'type' => Nomad_Form_Fields::NUMBER,
),
开/关按钮组
用法:Nomad_Form_Fields::ON_OFF_BUTTON_GROUP
具有预定义开和关选项的按钮组。
'example_on_off_button_group' => array(
'name' => 'example_on_off_button_group',
'label' => 'On Off Button Group',
'type' => Nomad_Form_Fields::ON_OFF_BUTTON_GROUP,
),
密码字段
用法:Nomad_Form_Fields::PASSWORD
密码输入字段。
'example_password' => array(
'name' => 'example_password',
'label' => 'Password Field',
'type' => Nomad_Form_Fields::PASSWORD,
),
百分比字段
用法:Nomad_Form_Fields::PERCENTAGE
最小值为0,最大值为100的数字输入字段。
'example_percentage' => array(
'name' => 'example_percentage',
'label' => 'Percentage Field',
'type' => Nomad_Form_Fields::PERCENTAGE,
),
电话字段
用法:Nomad_Form_Fields::PHONE
电话输入字段。
'example_phone' => array(
'name' => 'example_phone',
'label' => 'Phone Field',
'type' => Nomad_Form_Fields::PHONE,
),
单选按钮字段
用法:Nomad_Form_Fields::RADIO
单个单选按钮。
'example_radio' => array(
'name' => 'example_radio',
'label' => 'Radio Field',
'type' => Nomad_Form_Fields::RADIO,
'radio_text' => 'Radio text.',
),
单选按钮字段
用法:Nomad_Form_Fields::RADIOS
多个单选按钮。
'example_radios' => array(
'name' => 'example_radios',
'label' => 'Radios Field',
'type' => Nomad_Form_Fields::RADIOS,
'options' => array(
'a' => 'Choice A',
'b' => 'Choice B',
'c' => 'Choice C',
),
),
选择字段
用法:Nomad_Form_Fields::SELECT
选择下拉菜单。
'example_select' => array(
'name' => 'example_select',
'label' => 'Select Field',
'type' => Nomad_Form_Fields::SELECT,
'options' => array(
'a' => 'Choice A',
'b' => 'Choice B',
'c' => 'Choice C',
),
),
州字段
用法:Nomad_Form_Fields::STATE
选择下拉菜单,选项为美国各州。您可以使用format
指定full
(阿拉巴马州至怀俄明州)或short
(AL-WY)格式的选项。默认格式:short
。
'example_state' => array(
'name' => 'example_state',
'label' => 'State Field',
'type' => Nomad_Form_Fields::STATE,
),
文本字段
用法:Nomad_Form_Fields::TEXT
文本输入字段
'example_text' => array(
'name' => 'example_text',
'label' => 'Text Field',
'type' => Nomad_Form_Fields::TEXT,
),
文本区域字段
用法:Nomad_Form_Fields::TEXTAREA
文本区域。
'example_textarea' => array(
'name' => 'example_textarea',
'label' => 'Textarea Field',
'type' => Nomad_Form_Fields::TEXTAREA,
),
时间字段
用法:Nomad_Form_Fields::TIME
时间输入字段。
'example_time' => array(
'name' => 'example_time',
'label' => 'Time Field',
'type' => Nomad_Form_Fields::TIME,
),
切换字段
用法:Nomad_Form_Fields::TOGGLE
样式化复选框切换开关字段。
'example_toggle' => array(
'name' => 'example_toggle',
'label' => 'Toggle Field',
'type' => Nomad_Form_Fields::TOGGLE,
),
切换字段
用法:Nomad_Form_Fields::TOGGLES
样式化复选框切换开关字段。
'example_toggles' => array(
'name' => 'example_toggles',
'label' => 'Toggles Field',
'type' => Nomad_Form_Fields::TOGGLES,
'options' => array(
'a' => 'Choice A',
'b' => 'Choice B',
'c' => 'Choice C',
),
),
上传字段
用法:Nomad_Form_Fields::UPLOAD
文件输入字段。
'example_upload' => array(
'name' => 'example_upload',
'label' => 'Upload Field',
'type' => Nomad_Form_Fields::UPLOAD,
),
URL字段
用法:Nomad_Form_Fields::URL
URL输入字段。
'example_url' => array(
'name' => 'example_url',
'label' => 'Url Field',
'type' => Nomad_Form_Fields::URL,
),
星期字段
用法:Nomad_Form_Fields::WEEKDAY
选择下拉菜单,选项为一周中的天数。您可以使用format
指定full
(星期一到星期日)、short
(Mon-Sun)或lower
(monday-sunday)格式的选项。默认格式:lower
。
'example_weekday' => array(
'name' => 'example_weekday',
'label' => 'Weekday Field',
'type' => Nomad_Form_Fields::WEEKDAY,
),
年份字段
用法:Nomad_Form_Fields::YEAR
选择下拉菜单,选项为1900年至当前年份。您可以使用min
和max
确定哪些年份可以作为选项。
'example_year' => array(
'name' => 'example_year',
'label' => 'Year Field',
'type' => Nomad_Form_Fields::YEAR,
),
是/否按钮组
用法:Nomad_Form_Fields::YES_NO_BUTTON_GROUP
具有预定义是和否选项的按钮组。
'example_yes_no_button_group' => array(
'name' => 'example_yes_no_button_group',
'label' => 'Yes No Button Group',
'type' => Nomad_Form_Fields::YES_NO_BUTTON_GROUP,
),
保留字段名称
字段名称nomad_form_id
被保留,因为它用于确定提交的表单。这样就可以在同一页面上使用多个Nomad表单,并能够区分哪个被提交。
可用的钩子和过滤器
nomad/forms/init
/**
* Fires when first initializing a Nomad Form.
*
* @since 1.0.0
*
* @param string $form_id The form ID being initialized.
* @param array $args The form arguments.
*/
do_action( 'nomad/forms/init', $this->form_id(), $args );
nomad/forms/{$this->form_id()}/init
/**
* Fires when first initializing a specific Nomad Form.
*
* @since 1.0.0
*
* @param array $args The form arguments.
*/
do_action( "nomad/forms/{$this->form_id()}/init", $args );
nomad/forms/{$this->form_id()}/args
/**
* Filter the form arguments.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $args The form arguments.
*/
$args = apply_filters( "nomad/forms/{$this->form_id()}/args", $args );
nomad/forms/{$this->form_id()}/fields
/**
* Filter the form fields.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $fields The form fields.
*/
$args['fields'] = apply_filters( "nomad/forms/{$this->form_id()}/fields", $args['fields'] );
nomad/forms/{$this->form_id()}/injections
/**
* Filter form injections.
*
* It's recommended to use the `nomad_form_injection()` function instead of the filter directly.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $injections Form injections.
*/
$injections = apply_filters( "nomad/forms/{$this->form_id()}/injections", array() );
nomad/forms/before_form_open
/**
* Fires before the opening form tag.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/before_form_open', $this );
nomad/forms/{$this->form_id()}/before_form_open
/**
* Fires before the opening form tag for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/before_form_open", $this );
nomad/forms/form_open
/**
* Filters the opening form tag output.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param string $output The opening form tag output.
* @param Nomad_Form $this The form instance.
*/
$output = apply_filters( 'nomad/forms/form_open', $output, $this );
nomad/forms/{$this->form_id()}/form_open
/**
* Filters the opening form tag output for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param string $output The opening form tag output.
* @param Nomad_Form $this The form instance.
*/
$output = apply_filters( "nomad/forms/{$this->form_id()}/form_open", $output, $this );
nomad/forms/{$this->form_id()}/after_open
/**
* Fires after the opening form tag for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/after_open", $this );
nomad/forms/after_open
/**
* Fires after the opening form tag.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/after_open', $this );
nomad/forms/hidden_fields
/**
* Fires just after the `nomad_form_nonce` field in order to output
* additional hidden fields.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/hidden_fields', $this );
nomad/forms/{$this->form_id()}/hidden_fields
/**
* Fires just after the `nomad_form_nonce` field in order to output
* additional hidden fields of a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/hidden_fields", $this );
nomad/forms/before_fields_container
/**
* Fires before the form fields container.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/before_fields_container', $this );
nomad/forms/{$this->form_id()}/before_fields_container
/**
* Fires before the form fields container for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/before_fields_container", $this );
nomad/forms/before_fields
/**
* Fires before the form fields.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/before_fields', $this );
nomad/forms/{$this->form_id()}/before_fields
/**
* Fires before the form fields for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/before_fields", $this );
nomad/forms/{$this->form_id()}/field/{$field['name']}/args
/**
* Filters a specific form fields arguments.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $field The form field.
* @param Nomad_Form $this The form instance.
*/
$field = apply_filters( "nomad/forms/{$this->form_id()}/field/{$field['name']}/args", $field, $this );
nomad/forms/{$this->form_id()}/field/before
/**
* Fires before a fields output.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
* @param mixed $field The field being output.
*/
do_action( "nomad/forms/{$this->form_id()}/field/before", $this, $field );
nomad/forms/{$this->form_id()}/field/{$field['name']}/before
/**
* Fires before a fields output for a specific field.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
* @param mixed $field The field being output.
*/
do_action( "nomad/forms/{$this->form_id()}/field/{$field['name']}/before", $this, $field );
nomad/forms/{$this->form_id()}/field/{$field['name']}/after
/**
* Fires after a fields output for a specific field.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
* @param mixed $field The field being output.
*/
do_action( "nomad/forms/{$this->form_id()}/field/{$field['name']}/after", $this, $field );
nomad/forms/{$this->form_id()}/field/after
/**
* Fires after a fields output.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
* @param mixed $field The field being output.
*/
do_action( "nomad/forms/{$this->form_id()}/field/after", $this, $field );
nomad/forms/{$this->form_id()}/after_fields
/**
* Fires after the form fields for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/after_fields", $this );
nomad/forms/after_fields
/**
* Fires after the form fields.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/after_fields', $this );
nomad/forms/{$this->form_id()}/after_fields_container
/**
* Fires after the form fields container for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/after_fields_container", $this );
nomad/forms/after_fields_container
/**
* Fires before the form fields container.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/after_fields_container', $this );
nomad/forms/before_form_actions
/**
* Fires before the form actions.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/before_form_actions', $this );
nomad/forms/{$this->form_id()}/before_form_actions
/**
* Fires before the form actions for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/before_form_actions", $this );
nomad/forms/submit_attributes
/**
* Filters the submit button attributes.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $submit_attributes The submit button attributes.
* @param Nomad_Form $this The form instance.
*/
$submit_attributes = apply_filters( 'nomad/forms/submit_attributes', $submit_attributes, $this );
nomad/forms/{$this->form_id()}/submit_attributes
/**
* Filters the submit button attributes for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $submit_attributes The submit button attributes.
* @param Nomad_Form $this The form instance.
*/
$submit_attributes = apply_filters( "nomad/forms/{$this->form_id()}/submit_attributes", $submit_attributes, $this );
nomad/forms/before_submit_button
/**
* Fires before the submit button.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/before_submit_button', $this );
nomad/forms/{$this->form_id()}/before_submit_button
/**
* Fires before the submit button for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/before_submit_button", $this );
nomad/forms/{$this->form_id()}/after_submit_button
/**
* Fires after the submit button for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/after_submit_button", $this );
nomad/forms/after_submit_button
/**
* Fires after the submit button.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/after_submit_button', $this );
nomad/forms/{$this->form_id()}/after_form_actions
/**
* Fires after the form actions for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/after_form_actions", $this );
nomad/forms/after_form_actions
/**
* Fires after the form actions.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/after_form_actions', $this );
nomad/forms/reset_attributes
/**
* Filters the reset button attributes.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $reset_attributes The reset button attributes.
* @param Nomad_Form $this The form instance.
*/
$reset_attributes = apply_filters( 'nomad/forms/reset_attributes', $reset_attributes, $this );
nomad/forms/{$this->form_id()}/reset_attributes
/**
* Filters the reset button attributes for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $reset_attributes The reset button attributes.
* @param Nomad_Form $this The form instance.
*/
$reset_attributes = apply_filters( "nomad/forms/{$this->form_id()}/reset_attributes", $reset_attributes, $this );
nomad/forms/cancel_attributes
/**
* Filters the cancel button attributes.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $cancel_attributes The cancel button attributes.
* @param Nomad_Form $this The form instance.
*/
$cancel_attributes = apply_filters( 'nomad/forms/cancel_attributes', $cancel_attributes, $this );
nomad/forms/{$this->form_id()}/cancel_attributes
/**
* Filters the cancel button attributes for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $cancel_attributes The cancel button attributes.
* @param Nomad_Form $this The form instance.
*/
$cancel_attributes = apply_filters( "nomad/forms/{$this->form_id()}/cancel_attributes", $cancel_attributes, $this );
nomad/forms/form_close
/**
* Filters the closing form tag output.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param string $output The closing form tag output.
* @param Nomad_Form $this The form instance.
*/
$output = apply_filters( 'nomad/forms/form_close', $output, $this );
nomad/forms/{$this->form_id()}/form_close
/**
* Filters the closing form tag output for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param string $output The closing form tag output.
* @param Nomad_Form $this The form instance.
*/
$output = apply_filters( "nomad/forms/{$this->form_id()}/form_close", $output, $this );
nomad/forms/{$this->form_id()}/before_form_close
/**
* Fires before the closing form tag for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/before_form_close", $this );
nomad/forms/before_form_close
/**
* Fires before the closing form tag.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/before_form_close', $this );
nomad/forms/{$this->form_id()}/after_form_close
/**
* Fires after the closing form tag for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/after_form_close", $this );
nomad/forms/after_form_close
/**
* Fires after the closing form tag.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/after_form_close', $this );
nomad/forms/{$this->form_id()}/is_valid
/**
* Filters whether or not the form submission is valid.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param boolean $is_valid Whether or not the form submission is valid.
* @param Nomad_Form $this The form instance.
*/
$is_valid = apply_filters( "nomad/forms/{$this->form_id()}/is_valid", $is_valid, $this );
nomad/forms/{$this->form_id()}/success
/**
* Fires when a specific form is submitted successfully.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/success", $this );
nomad/forms/{$this->form_id()}/error
/**
* Fires when a specific form submission encounters an error.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/error", $this );
nomad/forms/process
/**
* Fires every time a form is submitted, regardless of whether
* or not it was valid.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( 'nomad/forms/process', $this );
nomad/forms/{$this->form_id()}/process
/**
* Fires every time a specific form is submitted regardless of
* whether or not it was valid.
*
* @since 1.0.0
*
* @param Nomad_Form $this The form instance.
*/
do_action( "nomad/forms/{$this->form_id()}/process", $this );
nomad/forms/{$this->form_id()}/success_message
/**
* Filter the form submission success message for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param string $success_message The success message for the form.
*/
$success_message = apply_filters( "nomad/forms/{$this->form_id()}/success_message", $success_message );
nomad/forms/{$this->form_id()}/error_message
/**
* Filter the form submission error message for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param string $error_message The error message for the form.
*/
$error_message = apply_filters( "nomad/forms/{$this->form_id()}/error_message", $error_message );
nomad/forms/{$this->form_id()}/error_messages
/**
* Filter the form submission error messages for a specific form.
*
* Can only be used if the form allows modifications.
*
* @since 1.0.0
*
* @param array $error_messages The error messages generated when validating form fields.
*/
$error_messages = apply_filters( "nomad/forms/{$this->form_id()}/error_messages", $this->messages );
变更日志
v1.0.0
- 初始发布
许可协议
MIT 许可协议 (MIT)。请参阅 许可文件 了解更多信息。
版权
版权 (c) 2021 Jake Sutherland