Home Forums ACF PRO Disable specific fields within admin Reply To: Disable specific fields within admin

  • Thanks, Elliot. This is helpful. What are the other parameters we can use here? For example, can we target a specific field by name or all fields within a specific repeater?

    To get some insight, here is our current code that works well, but not sure if it is the best way about it. For example, if you decide to change the class names (which you did in a recent update, this approach will break):

    acf.add_action('load', function($el){
              // Loop through each ACF field
                // Specific for Repeaters
                var table = $(this).parents('.acf-table-wrap'), // Get the table wrapper for the repeater
                    row = table.parent('.acf-row'), // Get the acf-row containing everything
                    hidden = table.find('[data-name="<?php echo self::UNIQUE_ID_FIELD_NAME; ?>"] input'); // Get the unique_id hidden field
                // Check if the unique_id field has a value
                if(hidden.length != 0 && hidden.val().length != 0){
                  // We are looking at a parent item since the unique_id is set
                  var remove_row = row.find('.acf-repeater-remove-row'),
                      input = $(this).find('.acf-input'), // Get the input wrapper for the field
                      field_name = $(this).data('name'),
                      field_type = $(this).data('type'),
                      field = null,
                      data = null;
                  if(field_type == 'wysiwyg'){
                    field = input.find('.acf-editor-wrap');
                    data = field.find('textarea').val();
                  } else {
                      case '<?php echo self::ACF_TOPIC_TITLE; ?>':
                        field = input.find('input');
                        data = field.val();
                  if(field != null){
                    // Hide the entire WYSIWYG field
                    // Hide remove icon/ability
                    remove_row.css('visibility', 'hidden');
                    // Display the data from the WYSIWYG field
                // End Repeaters