我是yii框架的新手。 我正在尝试编辑数据,我无法在文本框中显示数据,这是更新数据的第一步。我的控制器是sitecontroller.php
,我的视图文件update-jobseeker.php
。我有5个表user
,job_seeker_profile
,job_profile
,location
和category
。
我收到错误"Fatal error: Call to a member function isAttributeRequired() on a non-object in C:\wamp\www\yii_new\framework\web\helpers\CHtml.php on line 1414"
我的控制器是sitecontroller
,它的操作是:
<?php
public function actionupdate_jobseeker()
{
$id=$_GET['id'];
$model = Yii::app()->db->createCommand()
->select('*')
->from('user u')
->join('job_seeker_profile s','u.id = s.user_id')
->join('job_profile j','u.id = j.user_id')
->join('location l','l.id = s.location_id')
->join('category c','c.id = j.category_id')
->where('u.id=:id', array(':id'=>$id))
->QueryAll();
$this->render('update_jobseeker',array('model' =>$model));
}
?>
我的观看文件为update_jobseeker.php
<div>
<div style="float:right;margin-right:285px;">
<h1>Update Personal Detail</h1>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'login-form',
'enableClientValidation'=> false,
'htmlOptions' => array(),
'clientOptions'=> array(
'validateOnSubmit'=> true
),
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<div class="row">
<?php echo $form->labelEx($model,'Mobile No'); ?>
<?php echo $form->textField($model,'contact_no'); ?>
<?php echo $form->error($model,'contact_no'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div>
</div>
有人帮帮我吗?
答案 0 :(得分:0)
如果您的型号名称为User,则Active记录查找将如下:
$criteria = new CDbCriteria();
$criteria->join = 'job_seeker_profile s On t.id = s.user_id
inner join job_profile j ON t.id = j.user_id
inner join location l ON l.id = s.location_id
inner join category c ON c.id = j.category_id';
$criteria->compare('t.id' , id);
$model = User::model()->find($criteria);