title: Yii Restful API will create on POST but not populate any variables
body: <p>Hello I am currently trying to use POSTMAN to test an early API that is based of of this post
  <a href="http://www.yiiframework.com/wiki/175/how-to-create-a-rest-api/" rel="nofollow">http://www.yiiframework.com/wiki/175/how-to-create-a-rest-api/</a></p>
  
  <p>I am having an error when trying to either submit variables via POST in php url style or even sending an object. The response from the API comes back 200 and it creates a new entry into the database, but unfortunately it will not take any info from the post variables or jason object, it just comes up null. It seems now that that code is just looking through $_POST variables to and trying to match them to a model variable and if so, it should update it save it, However when i try to send through url parameters in POSTMAN or even change content type json and send raw json object I seem to have no luck with it.</p>
  
  <p>Also I really only need it to decode a jason object and not post parameters so maybe that is where I will start by removing the $post loop and working on retrieving a JSON object instead. Thanks for any help!</p>
  
  <pre><code>public function actionCreate()
  {
      switch($_GET['model'])
      {
          // Get an instance of the respective model
          case 'event':
              $model = new Event;                    
              break; 
          case 'media':
              $model = new Media;                    
              break; 
          case 'comment':
              $model = new Comment;                    
              break;
          default:
              $this-&gt;_sendResponse(501, 
                  sprintf('Mode &lt;b&gt;create&lt;/b&gt; is not implemented for model &lt;b&gt;%s&lt;/b&gt;',
                  $_GET['model']) );
                  Yii::app()-&gt;end();
      }
      // Try to assign POST values to attributes
      foreach($_POST as $var=&gt;$value) {
          // Does the model have this attribute? If not raise an error
          if($model-&gt;hasAttribute($var))
              $model-&gt;$var = $value;
          else
              $this-&gt;_sendResponse(500, 
                  sprintf('Parameter &lt;b&gt;%s&lt;/b&gt; is not allowed for model &lt;b&gt;%s&lt;/b&gt;', $var,
                  $_GET['model']) );
      }
      // Try to save the model
      if($model-&gt;save())
          $this-&gt;_sendResponse(200, CJSON::encode($model));
      else {
          // Errors occurred
          $msg = "&lt;h1&gt;Error&lt;/h1&gt;";
          $msg .= sprintf("Couldn't create model &lt;b&gt;%s&lt;/b&gt;", $_GET['model']);
          $msg .= "&lt;ul&gt;";
          foreach($model-&gt;errors as $attribute=&gt;$attr_errors) {
              $msg .= "&lt;li&gt;Attribute: $attribute&lt;/li&gt;";
              $msg .= "&lt;ul&gt;";
              foreach($attr_errors as $attr_error)
                  $msg .= "&lt;li&gt;$attr_error&lt;/li&gt;";
              $msg .= "&lt;/ul&gt;";
          }
          $msg .= "&lt;/ul&gt;";
          $this-&gt;_sendResponse(500, $msg );
      }
  }
  </code></pre>