重力形式。我尝试在渲染表单字段之前对其进行操作
add_filter("gform_pre_render", "my_function", 10, 5);
function my_function($form){
...
$form["fields"][0]["content"] = \'This is a html-block\'
}
这样,我可以传递html块的内容,假设html是表单上的第一个字段。如何通过id
? 假设上面的html块字段具有字段id13
.重力形式。我尝试在渲染表单字段之前对其进行操作
add_filter("gform_pre_render", "my_function", 10, 5);
function my_function($form){
...
$form["fields"][0]["content"] = \'This is a html-block\'
}
这样,我可以传递html块的内容,假设html是表单上的第一个字段。如何通过id
? 假设上面的html块字段具有字段id13
.根据this page about the form fields object, 看起来您需要这样做:
$my_id = \'37\';
foreach($form[\'fields\'] as $field){
if($field[\'id\'] == $my_id){
$field[\'content\'] = \'This is a html-block\';
}
}
在哪里$my_id
是目标字段的id