Created
July 28, 2022 07:07
-
-
Save santanup789/0b54a69093278dba072cb32a182646b0 to your computer and use it in GitHub Desktop.
Render Read only and Disable option for any ACF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Just repeat this add_action hook available for the ACF plugin | |
//add_action('acf/render_field_settings/type=text', 'add_readonly_and_disabled_to_text_field'); | |
//for the other types of fields be just changing the value of the type in the hook "/type=text". | |
//e.g. add_action('acf/render_field_settings/type=textarea', 'add_readonly_and_disabled_to_text_field'); | |
//It will add 2 radio option read-only and disable the field for the textarea field. | |
<?php | |
add_action('acf/render_field_settings/type=textarea', 'add_readonly_and_disabled_to_text_field'); | |
add_action('acf/render_field_settings/type=text', 'add_readonly_and_disabled_to_text_field'); | |
function add_readonly_and_disabled_to_text_field($field) { | |
acf_render_field_setting( $field, array( | |
'label' => __('Read Only?','acf'), | |
'instructions' => '', | |
'type' => 'radio', | |
'name' => 'readonly', | |
'choices' => array( | |
1 => __("Yes",'acf'), | |
0 => __("No",'acf'), | |
), | |
'layout' => 'horizontal', | |
)); | |
acf_render_field_setting( $field, array( | |
'label' => __('Disabled?','acf'), | |
'instructions' => '', | |
'type' => 'radio', | |
'name' => 'disabled', | |
'choices' => array( | |
1 => __("Yes",'acf'), | |
0 => __("No",'acf'), | |
), | |
'layout' => 'horizontal', | |
)); | |
} | |
?> |
Author
santanup789
commented
Jul 28, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment