title: yii call to a member function isAttributeRequired() on a non-object
body: <p>I get an error</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function isAttributeRequired() on a
    non-object in C:\xampp\htdocs\yii\framework\web\helpers\CHtml.php on
    line 1414.</p>
  </blockquote>
  
  <p>I have two tables Party and customers, I want edit party view in one form with customers fields</p>
  
  <p>in my controller</p>
  
  <pre><code>public function actionUpdate($id)
      {
          //$party_form = new Party;
          //$customer_form = new Customer;
  
          $model=$this-&gt;loadModel($id);
          $customer_form=$this-&gt;loadCusModel($id);
  
          // Uncomment the following line if AJAX validation is needed
          // $this-&gt;performAjaxValidation($model);
  
          if(isset($_POST['Party'], $_POST['Customer']))
          {
              $model-&gt;attributes=$_POST['Party'];
              $customer_form-&gt;attributes=$_POST['Customer'];
  
              if($model-&gt;save())
                  $this-&gt;redirect(array('view','id'=&gt;$model-&gt;id));
          }
  
          $this-&gt;render('update',array(
              'model'=&gt;$model,
              'customer_form'=&gt;$customer_form,
          ));
      }
  ........
  public function loadModel($id)
      {   
          $model=Party::model()-&gt;with()-&gt;findByPk((int)$id);
          //$model=Party::model()-&gt;with(array('customer'=&gt; array('select'=&gt;'first_name, mobile, phone, type')))-&gt;findByPk($id);
          if($model===null)
              throw new CHttpException(404,'The requested page does not exist.');
          return $model;
      }
  
  
      public function loadCusModel($id)
      {   
  
          $customer_form=Customer::model()-&gt;with()-&gt;findByPk($id);
  
          /*
          $cmd = Yii::app()-&gt;db-&gt;createCommand();
          $cmd-&gt;select = 'party.account_title';
          $cmd-&gt;from = 'customer, party';
          $cmd-&gt;where = 'customer.id=party.customer_id';
          $cmd-&gt;andWhere("party.id=$id");
          $row = $cmd-&gt;queryRow();
  
          $customer_form=$row;
          if($customer_form===null)
              throw new CHttpException(404,'The requested page does not exist.');
          return $party_form;
  
          */
          if($customer_form===null) {
              throw new CHttpException(404,'The requested page does not exist.');
          return $customer_form;
  
  
          }
  
  
      }
  </code></pre>
  
  <p>In update.php</p>
  
  <pre><code>&lt;?php
  /* @var $this PartyController */
  /* @var $model Party */
  
  $this-&gt;breadcrumbs=array(
      'Parties'=&gt;array('index'),
      $model-&gt;id=&gt;array('view','id'=&gt;$model-&gt;id),
      'Update',
  );
  
  $this-&gt;menu=array(
      array('label'=&gt;'List Party', 'url'=&gt;array('index')),
      array('label'=&gt;'Create Party', 'url'=&gt;array('create')),
      array('label'=&gt;'View Party', 'url'=&gt;array('view', 'id'=&gt;$model-&gt;id)),
      array('label'=&gt;'Manage Party', 'url'=&gt;array('admin')),
  );
  ?&gt;
  
  &lt;h1&gt;Update Party &lt;?php echo $model-&gt;id; ?&gt;&lt;/h1&gt;
  
  &lt;?php $this-&gt;renderPartial('_formUpd', array('model'=&gt;$model, 'customer_form'=&gt;$customer_form)); ?&gt;
  </code></pre>
  
  <p>and _formUpd.php</p>
  
  <pre><code>&lt;?php
  /* @var $this PartyController */
  /* @var $model Party */
  /* @var $form CActiveForm */
  ?&gt;
  
  &lt;div class="form"&gt;
  
  &lt;?php $form=$this-&gt;beginWidget('CActiveForm', array(
      'id'=&gt;'party-formUpd',
      // Please note: When you enable ajax validation, make sure the corresponding
      // controller action is handling ajax validation correctly.
      // There is a call to performAjaxValidation() commented in generated controller code.
      // See class documentation of CActiveForm for details on this.
      'enableAjaxValidation'=&gt;false,
      'htmlOptions' =&gt; array(
              'autocomplete' =&gt; 'off',
  
  
      )
  )); ?&gt;
  
      &lt;p class="note"&gt;Fields with &lt;span class="required"&gt;*&lt;/span&gt; are required.&lt;/p&gt;
  
      &lt;?php echo $form-&gt;errorSummary($model); ?&gt;
      &lt;?php //echo $form-&gt;errorSummary($customer_form); ?&gt;
  
      &lt;div class="row"&gt;
          &lt;?php echo $form-&gt;labelEx($customer_form,'first_name'); ?&gt;
          &lt;?php echo $form-&gt;textField($customer_form,'first_name',array('size'=&gt;30,'maxlength'=&gt;30, 'style' =&gt; 'text-transform:uppercase')); ?&gt;
          &lt;?php echo $form-&gt;error($customer_form,'first_name'); ?&gt;
      &lt;/div&gt;
  
      &lt;div class="row"&gt;
          &lt;?php //echo $form-&gt;labelEx($model,'last_name'); ?&gt;
          &lt;?php //echo $form-&gt;textField($model,'last_name',array('size'=&gt;30,'maxlength'=&gt;30, 'style' =&gt; 'text-transform:uppercase')); ?&gt;
          &lt;?php //echo $form-&gt;error($model,'last_name'); ?&gt;
      &lt;/div&gt;
  
      ............    
  
      &lt;div class="row buttons"&gt;
          &lt;?php //echo CHtml::submitButton($party_form-&gt;isNewRecord ? 'Create' : 'Save'); ?&gt;
          &lt;?php
          $this-&gt;widget('bootstrap.widgets.TbButton', array('buttonType'=&gt;'submit', 'type'=&gt;'primary', 'label'=&gt;'Submit', 'size'=&gt;'large'));
  ?&gt;
      &lt;/div&gt;
  
  &lt;?php $this-&gt;endWidget(); ?&gt;
  
  &lt;/div&gt;&lt;!-- form --&gt;
  </code></pre>
  
  <p>Please Help..</p>