title: yii not saving model
body: <pre><code>  $model=new Event('create');
    $model-&gt;attributes=$_POST['Event'];
    if($model-&gt;save()){
      $pkg = new Package(); 
      $pkg-&gt;attributes=$_POST['Package'];
      $pkg-&gt;event_id = $model-&gt;id;
      $pkg-&gt;save();
    }
  </code></pre>
  
  <p>The Event model gets saved correctly with all the POST variables for Event, while the Package only has the event_id set, but no attributes are set (they are all NULL). What am I doing wrong?</p>
  
  <p>NB: The Event object has been programmed by my predecessor, the Package object is a new addition I did.</p>
  
  <p>EDIT: the whole Package class</p>
  
  <pre><code>  class Package extends CActiveRecord
    { 
    public static function model($className=__CLASS__)
    {
      return parent::model($className);
    }
  public function tableName()
    {
      return 'tbl_package';
    }
   public function rules()
    {
      // NOTE: you should only define rules for those attributes that
      // will receive user inputs.
      return array(
        // The following rule is used by search().
        // Please remove those attributes that should not be searched.
        array('', 'safe', 'on'=&gt;'search'),
        array('', 'numerical'),
      );
    }public function relations()
    {
      // NOTE: you may need to adjust the relation name and the related
      // class name for the relations automatically generated below.
      return array(
        'event' =&gt; array(self::BELONGS_TO, 'Event', 'id')
      );
    }public function attributeLabels()
    {
      return array(
        'event_id'      =&gt; 'Event ID',
        'package_name'  =&gt; 'Package name',
        'event_banner'  =&gt; 'Event Banner',
        'ad_placement'  =&gt; 'Ad Placement in Event Program',
        'logo_on_step'  =&gt; 'Logo on Step &amp; Repeat',
        'use_evt_pics'  =&gt; 'Usage of Event Pictures',
        'exhibition'    =&gt; 'Exhibition Booth/Space',
        'inc_press'     =&gt; 'Inclusion in Press',
        'print_ads'     =&gt; 'Insertion in Print Ads',
        'online_ads'    =&gt; 'Insertion in Online Ads',
        'attendee_bags' =&gt; 'Attendee Bags',
        'charging_st'   =&gt; 'Charging Stations',
        'cups'          =&gt; 'Coffee/Water Cups',
        'distr_items'   =&gt; 'Distributable Items',
        'lanyards'      =&gt; 'Lanyards',
        'napkins'       =&gt; 'Napkins',
        'notebooks'     =&gt; 'Notebooks',
        'pens'          =&gt; 'Pens',
        'seat_covers'   =&gt; 'Seat Covers',
        'snack_pack'    =&gt; 'Snack Packaging',
        'water_bottles' =&gt; 'Water Bottles'
      );
    } public function search()
    {
      // Warning: Please modify the following code to remove attributes that
      // should not be searched.
  
      $criteria=new CDbCriteria;
      $criteria-&gt;compare('event_banner',$this-&gt;event_banner);
      $criteria-&gt;compare('package_name',$this-&gt;package_name);
      $criteria-&gt;compare('ad_placement',$this-&gt;ad_placement);
      $criteria-&gt;compare('logo_on_step',$this-&gt;logo_on_step);
      $criteria-&gt;compare('use_evt_pics',$this-&gt;use_evt_pics);
      $criteria-&gt;compare('exhibition',$this-&gt;exhibition);
      $criteria-&gt;compare('inc_press',$this-&gt;inc_press);
      $criteria-&gt;compare('print_ads',$this-&gt;print_ads);
      $criteria-&gt;compare('online_ads',$this-&gt;online_ads);
      $criteria-&gt;compare('attendee_bags',$this-&gt;attendee_bags);
      $criteria-&gt;compare('charging_st',$this-&gt;charging_st);
      $criteria-&gt;compare('cups',$this-&gt;cups);
      $criteria-&gt;compare('distr_items',$this-&gt;distr_items);
      $criteria-&gt;compare('lanyards',$this-&gt;lanyards);
      $criteria-&gt;compare('napkins',$this-&gt;napkins);
      $criteria-&gt;compare('notebooks',$this-&gt;notebooks);
      $criteria-&gt;compare('pens',$this-&gt;pens);
      $criteria-&gt;compare('seat_covers',$this-&gt;seat_covers);
      $criteria-&gt;compare('snack_pack',$this-&gt;snack_pack);
      $criteria-&gt;compare('water_bottles',$this-&gt;water_bottles);
  
      return new CActiveDataProvider('SponsorshipPackage', array(
        'criteria'=&gt;$criteria,
      ));
    }
  }
  </code></pre>