wordpress - 重力表单在提交时动态填充单选按钮为空
问题描述
我想从 wordpress 术语中动态添加单选按钮,但我想将其保存到数据库中。如果需要,则检查将是错误的。可以帮助理解为什么重力形式的示例不适用于单选按钮吗?
这是我的代码:
add_filter('gform_pre_render_1', 'populate_cat_members');
add_filter('gform_pre_validation_1', 'populate_cat_members' );
add_filter('gform_pre_submission_filter_1', 'populate_cat_members' );
add_filter('gform_admin_pre_render_1', 'populate_cat_members');
function populate_cat_members($form)
{
foreach ($form['fields'] as $field) {
if ($field['id'] == 32) {
$terms = get_terms('cat_members', array('hide_empty' => false, 'oderby' => 'name'));
$choices = array();
$numItems = count($terms);
foreach ($terms as $post) {
$choices[] = array('text' => $post->name, 'value' => $post->term_id);
}
$field->choices = $choices;
}
}
return $form;
}
谁能帮帮我,为什么我不能保存数据?
解决方案
推荐阅读
- aws-fargate - 如何调试内存不足的aws fargate任务?
- azure-devops - 2 个 azure 管道之间的非干扰管道触发
- firebase - 无法通过 `CompileOptions.compilerArgs` 指定 -processorpath 或 --processor-path。改用 `CompileOptions.annotationProcessorPath` 属性
- php - Recaptcha V3 在加/减 20 次提交表单后返回分数 0.1(同时调整这些页面)
- java - “合并”数据或“设置”数据,MediatorLiveData
- c - 在 main 之外分配变量:数据定义没有类型或存储类
- google-play - 仅针对新用户的 Google 订阅价格上涨
- reactjs - React Native 通过 id 查找
- vba - 在 ETAS INCA 中,如何通过 VBA 访问 COM-API 来提取特定的校准值?
- python - 如何通过无限一维数组垂直填充数组