You may want to merge this into my previous thread, as I thought I'd solved it, but haven't :(
Problem arises when unsetting a required field - it's still required. So, I need something extra here, but not sure what.
function sd_hide_or_require_insured($form){
$insuredfield = array('Insured');
global $post;
$needsinsurance = get_post_meta($post->ID,'_sd_prod_insurance',true);
if ($needsinsurance==1) {
//make the field required - but how?
} else {
foreach($form['fields'] as $key=>$field) {
if(in_array($field['label'], $insuredfield)) {
unset($form['fields'][$key]);
//or alternatively make it not required if value is 0, as well as unsetting
}
}
}
return $form;
}
Any help really appreciated.