我已经使用一些php挂钩动态填充了Gravity Form的单选按钮字段。
单选按钮可以在前端和管理端正确显示。但是无法提交表格。
无论何时任何用户尝试提交表单,都会说需要单选按钮(即使已选择按钮中的一个选项)。
我尝试关闭必需的选项,在这种情况下,单选按钮的值不会记录在数据库中。
我的代码如下。我在做错什么吗?
function get_quote_date_radio_button_1($form)
{
date_default_timezone_set(get_option('timezone_string'));
$field_id = 36; // Change this if field id changes
$hour = date("H");
if( intval($hour) < 22) {
$midnight = "Midnight Tonight";
$tomorrow = "Tomorrow (" . date('l,jS F',strtotime($today. ' + 1 day')) . ")";
} else {
$midnight = "Midnight Tomorrow";
$tomorrow = date('l,strtotime($today. ' + 2 day'));
}
$choices = array(
array("text" => $midnight,"value" => $midnight),array("text" => $tomorrow,"value" => $tomorrow),array("text" => "3-5 working days","value" => "3-5 working days")
);
$inputs = array(
array("label" => $midnight,"id" => "$field_number.0"),array("label" => $tomorrow,"id" => "$field_number.1"),array("label" => "3-5 working days","id" => "$field_number.2"),);
foreach($form["fields"] as $field){
if($field["id"] == $field_id){
$field["choices"] = $choices;
$field["inputs"] = $inputs;
}
}
return $form;
}