title: TYPO3 Extbase how to empty ObjectStorage
body: <p>I want to "empty" an ObjectStorage when updating a Object:</p>
  
  <p>It's TYPO3 4.6 with a Extbase Extension which allows you to show/add/edit/delete datasets in the frontend. At first sight everything looks good. </p>
  
  <p>I have one field referencing another table:</p>
  
  <p><strong>TCA:</strong></p>
  
  <pre><code>'partner' =&gt; array(
  'exclude' =&gt; 0,
  'label' =&gt; 'LLL:EXT:toco3_marketingdb/Resources/Private/Language/locallang_db.xlf:tx_toco3marketingdb_domain_model_firma.partner',
  'config' =&gt; array(
  'type' =&gt; 'select',
  'size' =&gt; 5,
  'foreign_table' =&gt; 'tx_toco3marketingdb_domain_model_partner',
  'foreign_table_where' =&gt; 'ORDER BY tx_toco3marketingdb_domain_model_partner.partnerpkey',
  'minitems' =&gt; 0,
  'maxitems' =&gt; 20,
  ),
  ),
  </code></pre>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>/**
  * Partner
  *
  * @var Tx_Extbase_Persistence_ObjectStorage&lt;Tx_Toco3Marketingdb_Domain_Model_Partner&gt;
  * @lazy
  */
  protected $partner;
  /**
  * Sets the partner
  *
  * @param Tx_Extbase_Persistence_ObjectStorage&lt;Tx_Toco3Marketingdb_Domain_Model_Partner&gt; $partner
  * @return void
  */
  public function setPartner(Tx_Extbase_Persistence_ObjectStorage $partner) {
  $this-&gt;partner = $partner;
  }
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>$partner = new Tx_Extbase_Persistence_ObjectStorage();
  if (count($partnerarr) &gt; 0){
  foreach($partnerarr as $p){
  $partner-&gt;attach( $this-&gt;partnerRepository-&gt;findByUid($p));
  }
  }
  $organisation = $this-&gt;organisationRepository-&gt;findByUid($uid)
  $organisation-&gt;setPartner($partner);
  </code></pre>
  
  <p>This is working as long there is an Object in the ObjectStorage. So I can add/delete/change relations. But when $partnerarr is empty an no objects get attached an empty Tx_Extbase_Persistence_ObjectStorage is assigned, the old values do not get "deleted". I also tried to assign null or "" but the an error occures because an ObjectStorage is needed. If I assign the empty ObjectStorage I don't get an error, but the old values still maintain :(</p>
  
  <p>Any idea?</p>
  
  <p>Thank you</p>
  
  <p>Christian</p>