title: cakephp set values to model before saving form data
body: <p>i'm learning CakePHP. I want to submit form data to database and just before saving, I wish to modify few fields. Here is what I tried:</p>
  
  <pre><code>public function addProduct() {
  
      $this-&gt;layout = false;
      $this-&gt;render ( false );
  
      $this-&gt;loadModel ( 'Product' );
  
      $this-&gt;Product-&gt;create();
  
      $conditions = array('Product.category_id' =&gt; $this-&gt;request-&gt;data["categoryproduct"],
                          'Product.company_id' =&gt; $this-&gt;request-&gt;data["companyproduct"],
                          'Product.name' =&gt; $this-&gt;request-&gt;data["name"]
                      );
  
      $product = $this-&gt;Product-&gt;find ( 'first', array ('conditions' =&gt; $conditions ) );
  
      if ($product)
          echo "duplicate";
      else{
  
          $discount = $this-&gt;request-&gt;data["discount"];
  
          if($discount&gt;0){
              $cost = $this-&gt;request-&gt;data["cost"];
              $this-&gt;Product-&gt;costforyou = intval($cost - $cost * $discount / 100);
          }
          else
              $this-&gt;Product-&gt;costforyou = 0;
  
          $this-&gt;Product-&gt;category_id = $this-&gt;request-&gt;data["categoryproduct"];
          $this-&gt;Product-&gt;company_id = $this-&gt;request-&gt;data["companyproduct"];
          $this-&gt;Product-&gt;create_date = date('Y-m-d h:i:s');
          $this-&gt;Product-&gt;status = "active";
  
          if ($this-&gt;Product-&gt;save($this-&gt;request-&gt;data)) {
              echo "Product added";
          } else {
              echo "Error in adding product";
          }
      }
  }
  </code></pre>
  
  <p>But all the fields that I'm setting manually are not getting their data. I tried to have a look at CakePHP books but couldn't find anything there.</p>