From 74039e5d5266db51610cd46ee628234e4474ddf0 Mon Sep 17 00:00:00 2001 From: AkeraYoui Date: Tue, 5 Sep 2023 00:56:18 +0300 Subject: [PATCH] Update class-acf-field-true_false.php This change is to add the ability to make the "true_false" field type "readonly" or "disabled"! --- includes/fields/class-acf-field-true_false.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/includes/fields/class-acf-field-true_false.php b/includes/fields/class-acf-field-true_false.php index ba411e65..6c836143 100644 --- a/includes/fields/class-acf-field-true_false.php +++ b/includes/fields/class-acf-field-true_false.php @@ -67,6 +67,14 @@ function render_field( $field ) { 'value' => 0, ); + if (!empty($field['readonly']) || !empty($field['disabled'])) { + $input['disabled'] = 'disabled'; + unset($input['name']); + + // if the field meant to be disabled, the element not mutable, focusable, or even submitted with the form. + $hidden['value'] = !empty($field['readonly']) && empty($field['disabled']) ? $field['value'] : 0; + } + $active = $field['value'] ? true : false; $switch = '';