
Hi
I’ve implemented for my ACF based CPT a frontend form with acf_form and acf_form_head, that works fine and all form submissions are processed fine.
Now I want to achieve the following:
– when creating a new CPT post all fields shall be editable
– when editing an existing CPT post several fields shall be read only/disabled, so that existing values cannot be overwritten – still the field shall be displayed
I’m able to disable the relevant fields via the filter acf/prepare_field with
function form_field_disable($field) {
switch ($field[‘_name’]) {
case …. :
$field[‘disabled’] = true;
break;
…
default:
break;
}
}
return $field;
}
The problem is, that although disabled on the UI an initial value is submitted in the POST request when submitting the form and the existing values are overwritten with an empty value.
Any hint how I can prevent this?
All validation filters for these disabled fields are called as well with an initial value (from the callstack this happens in some AJAX call).
Thanks for any hint.
Regards,
Bernd