title: How to save multiple values entered into ListBoxField and loop through values?
body: <p>I want to be able to associate team members to a project using the <code>ListBoxField</code> . I have a <code>ProjectHolder</code> which has <code>Project</code> pages as it's children. I also have a <code>TeamHolder</code> which has <code>TeamPage</code>'s as its children.</p>
  
  <p>I want to be able to save multiple team members in the <code>ListBoxField</code> and then loop through them on a <code>Project</code> page. I also want to be able to link to the team members pages. e.g</p>
  
  <pre><code>&lt;% loop $TeamMemberNames %&gt;
      &lt;a href="$Link"&gt;$Name&lt;/a&gt;
  &lt;% end_loop %&gt;
  </code></pre>
  
  <p><strong><em>My Current code:</em></strong></p>
  
  <p><strong>TeamPage.php</strong></p>
  
  <pre><code>class TeamPage extends Page
  {
      private static $db = array(
          'Name' =&gt; 'Varchar(255)',
      );
  
      public function getCMSFields() {
  
          $fields = parent::getCMSFields();
  
          $fields-&gt;addFieldToTab('Root.TeamMembers', TextField::create('Name'));
  
          return $fields;
      }
  }
  </code></pre>
  
  <p><strong>Project.php</strong></p>
  
  <pre><code>class Project extends Page
  {
      private static $db = array(
          'Name' =&gt; 'Varchar(255)',
      );
  
      public function getCMSFields() {
  
          $fields = parent::getCMSFields();
  
          $fields-&gt;addFieldToTab('Root.TeamMembers', TextField::create('Name'));
  
          $fields-&gt;addFieldToTab('Root.TeamMembers', ListBoxField::create(
              'TeamPage',
              'Select Team Members for project',
              TeamPage::get()-&gt;map("ID", "Name")-&gt;toArray()
          )-&gt;setMultiple(true));
  
          return $fields;
      }
  
  }
  </code></pre>
  
  <p><strong>Screenshot:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/1TmLJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1TmLJ.png" alt="enter image description here"></a></p>
  
  <p>I can pull through the names from the <code>TeamPage</code> Object into the <code>ListBoxField</code> however after selecting the names I need a way to save the multiple values and also get the Link so I can link to the appropriate team members pages that are listed. </p>