Im trying to prepopulate a checkbox based on whether a condition in another field within the same form is true.
here's the code i managed to pull together looking at various examples around the web. It would seem that my IF statment to update the choice is wonky, but I don't have sufficient syntax knowledge to correct it. Can you help?
add_filter( 'gform_pre_render_19', 'Cover_needed' );
function Cover_needed( $form ){
$VAR_Family_Home = $form_data['field'][2];
$VAR_Life_Style = $form_data['field'][3];
$VAR_Debt = $form_data['field'][4];
if( 1 === $field->id ) {
foreach( $field->choices as &$choice ){
if ($VAR_Family_Home < 3 'familyhome' === $choice['value'] || $VAR_Life_Style < 3 'lifestyle' === $choice['value'] || $VAR_Debt < 3 'debt' === $choice['value']){
$choice['isSelected'] = true;
}
}
}
return $form;
}
Thanks in advance Stuart
Aucun commentaire:
Enregistrer un commentaire