Support

Account

Home Forums Feature Requests Read-Only Field Reply To: Read-Only Field

  • I was messing about with something and I added the following to functions.php. I wasn’t really surprised when it worked since the disabled and readonly attributes already exist for all fields, this just makes them editable.

    
      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',
        ));
      }