sorry – I forgot to mention that this is a JS code. this code will only be loaded on the CPT with this fields.
Basically, it’s not that difficult to understand.
We differentiate here between deactivated fields for inputs, radio buttons, etc. – this information is extremely important!!! Because there are different behaviors for the different fields.
my problem was the radio buttons. if they are disabled via $field[‘disabled’], then they simply accept the value that you get by definition in the ACF configuration. No code, can then change their value.
My solution for the radio buttons is:
Find the radio button from the group that is not checked and disable it.
The values are overwritten by a mail class and cannot be set by the user.
It indicates whether a confirmation email has been sent or not.
$('[data-name="order_send_mail_on_order_to_admin"]').find(':radio:not(:checked)').prop('disabled', true);
Hi roidnachrisb
I have the same problem.
I have radio buttons (which show a status if emails have been sent).
I set them to disabled, because readonly isn’t possible, with the following code:
public function order_read_only_fields_radio_button($field)
{
$field['disabled'] = array(
// set each value option you want to disable
'0',
'1',
// etc
);
return $field;
}
I just spent hours trying to find out that I can’t retrieve the values (array or whatever – I tried everything) from these disabled radio fields using get_field.
It seems like only update_field works on these disabled fields.