original_string: protected function _getFormTabGroups(array $fields = [])
      {
          $action = $this->_action();
          $groups = $action->getConfig('scaffold.form_tab_groups');
  
          if (empty($groups)) {
              return [];
          }
  
          $groupedFields = (new Collection($groups))->unfold()->toList();
          $unGroupedFields = array_diff(array_keys($fields), $groupedFields);
  
          if (!empty($unGroupedFields)) {
              $primayGroup = $action->getConfig('scaffold.form_primary_tab') ?: __d('crud', 'Primary');
  
              $groups = [$primayGroup => $unGroupedFields] + $groups;
          }
  
          return $groups;
      }
code: protected function _getFormTabGroups(array $fields = [])
      {
          $action = $this->_action();
          $groups = $action->getConfig('scaffold.form_tab_groups');
  
          if (empty($groups)) {
              return [];
          }
  
          $groupedFields = (new Collection($groups))->unfold()->toList();
          $unGroupedFields = array_diff(array_keys($fields), $groupedFields);
  
          if (!empty($unGroupedFields)) {
              $primayGroup = $action->getConfig('scaffold.form_primary_tab') ?: __d('crud', 'Primary');
  
              $groups = [$primayGroup => $unGroupedFields] + $groups;
          }
  
          return $groups;
      }
code_tokens: protected function _getFormTabGroups ( array $ fields = [ ] ) { $ action = $ this -> _action ( ) ; $ groups = $ action -> getConfig ( 'scaffold.form_tab_groups' ) ; if ( empty ( $ groups ) ) { return [ ] ; } $ groupedFields = ( new Collection ( $ groups ) ) -> unfold ( ) -> toList ( ) ; $ unGroupedFields = array_diff ( array_keys ( $ fields ) , $ groupedFields ) ; if ( ! empty ( $ unGroupedFields ) ) { $ primayGroup = $ action -> getConfig ( 'scaffold.form_primary_tab' ) ? : __d ( 'crud' , 'Primary' ) ; $ groups = [ $ primayGroup => $ unGroupedFields ] + $ groups ; } return $ groups ; }
docstring: Get field tab groups
  
  @param array $fields Form fields.
  @return array
docstring_tokens: Get field tab groups