I am working on a form with 100+ fields, which is seperated in multiple pages.
In order to be able to test the form more fast i set NO field required.
If i want to set all fields required before release, I want to be able to do that via the functions.php.
Here is an Example, based on this
add_filter("gform_pre_render", "set_required");
add_filter("gform_validation", "check_required");
function set_required($form){
foreach($form["fields"] as &$field){
if ($field["type"] != "html")
{
$field["isRequired"] = true;}
}
return $form;
}
function check_required($validation_result){
foreach($validation_result["form"]["fields"] as &$field){
if ($field["type"] != "html")
{
if(GFFormDisplay::is_empty($field, $validation_result["form"]["id"])){
$field["failed_validation"] = true;
$field["validation_message"] = "This field is required.";
$validation_result["is_valid"] = false;
}
}
}
return $validation_result;}
The problem: it also sets my html fields to required, even that is not supposed to happen?
See isRequired