Tags field convert toPages()

Hey.

I have a multiselect for choosing partner to projects. So if I check the output on the frontend I got a string sepertet bei ‘,’ back. So I thougth I could put them to ->toPages().

$field->toPages(string $separator = 'yaml'): Kirby\Cms\Pages

On the doc is written " Can be any other separator to split the field value by"

echo $partner; ->>>>>> partner/XYZ, partner/ABC, partner/DEF, partner/ASD

$partner->toPages()

I know I could do something like that

 $items = [];
    foreach ($partner->split() as $item) {
      $items[] = page($item);
    }

But than i got an array back. And what i need is all pages cause i also need to filter them.
Maybe there is a way to keep them as stirng and pass them to ->toPages()?

Best regards

$page->partner()->toPages(',')for a comma separated list.

@texnixe That does not fit my needings.
I pass over a controller via return the page - for example its a project page.

In the project.yml i have:

title: Partner

columns:
  - width: 2/3
    sections:
      partner:
        label: Partner
        layout: cardlets
        type: pages
        search: true
        sort: true
        template: company
        sortBy: title

  - width: 1/3
    sections:
      content:
        type: fields
        fields: 
          categories:
            label: Kategorie
            type: tags

in my company.yml I have just some fields with mail, number, etc.

in my parnter.yml I have this

partner:
            type: fields
            fields:
              partner:
                label: Partner
                type: multiselect
                options:
                  type: query
                  query: site.find("partner").children

Now i fetch one project and there i have the field $partner cause i already pass it as return in my controller

 $partner =  $objectpage->partner();
....

      return [
              'partner' => $partner
          ];

and on the template where i output the $partner - I have that for testing


 <?php 
    print_r($partner);
   echo ($partner);
  ?>

Print_r gives me

  Kirby\Content\Field Object
(
    [partner] => partner/ABC, partner/DEF, partner/ZYF
)

echo gives me

partner/ABC, partner/DEF, partner/ZYF

And what I want to do


$allPartner = $partner->toPages()->filterBy('categories', 'VALUE');
foreach ($allPartner as $filterpartner) {
echo $filterpartner->title();
}

UPDATE:

I keep my text - But your solution works.
I don’t pass the field over the controller → instead i use the $page Object as you say.
In my case it’s $object cause i pass it over a controller.

$object->partner()->toPages(','))