Php 重力表单gform_pre_提交钩子是否适用于带有“下一步”按钮和多个步骤的表单?
我的表单有多个步骤 填写一些内容,单击“下一步”,然后填写更多内容 我担心的是,直到按下提交按钮的最后一刻,该功能才会启动 在这一点上,我将能够操作以前字段上的数据吗Php 重力表单gform_pre_提交钩子是否适用于带有“下一步”按钮和多个步骤的表单?,php,wordpress,gravity-forms-plugin,gravityforms,Php,Wordpress,Gravity Forms Plugin,Gravityforms,我的表单有多个步骤 填写一些内容,单击“下一步”,然后填写更多内容 我担心的是,直到按下提交按钮的最后一刻,该功能才会启动 在这一点上,我将能够操作以前字段上的数据吗 <?php //Change _6 to the form ID number everywhere add_action('gform_pre_submission_6', 'capitalize_fields_6'); function capitalize_fields_6($form){ //
<?php
//Change _6 to the form ID number everywhere
add_action('gform_pre_submission_6', 'capitalize_fields_6');
function capitalize_fields_6($form){
// add all the field IDs you want to capitalize, to this array
$fields_to_cap = array('input_id_here');
// add all uppercase first letter id's, to this array
$field_to_firstLetter = array('input_id_here');
foreach ($fields_to_cap as $each) {
// for each field, convert the submitted value to uppercase and assign back to the POST variable
// the rgpost function strips slashes
$_POST[$each] = strtoupper(rgpost($each));
}
foreach ($field_to_firstLetter as $each) {
$_POST[$each] = ucwords(rgpost($each));
}
// return the form, even though we did not modify it
return $form;
}
?>
钩子仅在表单实际发布之后,但在对表单中的数据进行任何重要处理之前触发
多页表单不会在页面之间提交任何内容,它或多或少只是将页面包装在块中,并基于块显示/隐藏它们-它只是设计为一种“更美观”的方式来呈现长表单,而不是在页面上有一个巨大的可滚动表单。该选项例外,但字段掩码/格式之外的内容实际上未经验证,且未通过gform_pre_submission
运行
如果您需要在以前的页面上“操作数据”,那么最好使用JavaScript的事件处理函数在数据提交之前(但在字段中键入数据之后)先发制人地更改数据。您还可以在所需的输入上使用CSS属性,并将其设置为大写
(注意,这只会影响显示,而不会影响实际值,因此您仍然需要通过gform\u pre\u submission
钩子运行它