title: CakePHP – 2 controllers, 1 form
body: <p>I need to create a review form. I have 2 models and 2 controllers – Products and Reviews with 'Products' hasMany 'Reviews' relationship, the review form will be displayed on the current product page (Products controller, 'view' action), and this form will be use another controller (Reviews).</p>
  
  <p>Also I need validation for this form with validation errors being displayed.</p>
  
  <p>In my Products controller view.ctp I have:</p>
  
  <pre><code>// product page stuff...
  
  echo $this-&gt;Form-&gt;create($model = 'Review', array('url' =&gt; '/reviews/add'));
  echo $this-&gt;Form-&gt;input('name', array('label' =&gt; 'Your name:'));
  echo $this-&gt;Form-&gt;input('email', array('label' =&gt; 'Your e-mail:'));
  echo $this-&gt;Form-&gt;input('message', array('rows' =&gt; '6', 'label' =&gt; 'Your message:'));
  echo $this-&gt;Form-&gt;hidden('product_id', array('default' =&gt; $product['Product']['id']));
  echo $this-&gt;Form-&gt;end('Send');
  
  echo $this-&gt;Session-&gt;flash();
  </code></pre>
  
  <p>ReviewsController -> add: </p>
  
  <pre><code>public function add() {
  if ($this-&gt;request-&gt;is('post')) {
      $this-&gt;Review-&gt;save($this-&gt;request-&gt;data); 
      $this-&gt;redirect(array('controller' =&gt; 'products', 'action' =&gt; 'view', $this-&gt;request-&gt;data['Review']['product_id'], '#' =&gt; 'reviews'));
      }
  }
  </code></pre>
  
  <p>Somehow this horrible code works.. in part.
  Review saves, but validation errors are not displaying.</p>
  
  <p>If I add If statement to this action:</p>
  
  <p>ReviewsController -> Add: </p>
  
  <pre><code>public function add() {
  if ($this-&gt;request-&gt;is('post')) {
      if ( $this-&gt;Review-&gt;save($this-&gt;request-&gt;data) ){ 
      $this-&gt;redirect(array('controller' =&gt; 'products', 'action' =&gt; 'view', $this-&gt;request-&gt;data['Review']['product_id'], '#' =&gt; 'reviews'));
      }}
  }
  </code></pre>
  
  <p>and if form have errors and didn't validates I get MissingView error:
      Missing View</p>
  
  <pre><code>Error: The view for ReviewsController::add() was not found.
  </code></pre>
  
  <p>My question is how to properly deal with this situation to achieve functionality that I need?
  Should I use elements with request action or I should move action for adding reviews to the ProductsController?</p>