title: CakePHP - access to associated model in beforeSave
body: <p>In my app Quotes belongTo a product, which in turn belongs to a material.  As I can't get the product model afterFind array to include the material when it is accessed from the Quote model I have associated the Quote directly with a material.</p>
  
  <p>The problem I'm having now is that the material_id for the quote needs to be automatically saved based on the product which is selected for the quote</p>
  
  <p>i.e. pulling the value of Product.material_id from the selected product and saving it to the Quote.material_id field automatically before the Quote has been saved to the database.</p>
  
  <p>I'm quite new to cakePHP.  Does anyone know how this can be done?</p>
  
  <p>EDIT:</p>
  
  <p>Here is an example to help explain. In my Quote model i can have:</p>
  
  <pre><code>public function beforeSave($options) {
      $this-&gt;data['Quote']['material_id'] = 4;
      return true;
  }
  </code></pre>
  
  <p>but i need to do something more like this which doesn't work:</p>
  
  <pre><code>public function beforeSave($options) {
      $this-&gt;data['Quote']['material_id'] = $this-&gt;Product['material_id'];
      return true;
  }
  </code></pre>