hi, I have set the current logged in users id , plus the hidden field, but then when I save the company details, it’s not being saved in the table, it was “null” why is that?
here’s my the index view code from where the log in user can click the create company link as you can see, the mid is set as Yii:app()->user-id
<?php
$this->breadcrumbs=array(
'Company Details',
);
$this->menu=array(
array('label'=>'Create Company Details', 'url'=>array('create','mid'=>Yii::app()->user->id)),
);
?>
<h1>Company Details</h1>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>
at the _form file , i have this part of the code. I have the hiddenField set
as the MemberShipID , it’s the column in my companies table
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'wsmembersdetails-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->hiddenField($model,'MemberShipID'); ?>
</div>
here’s my actionCreate()
public function actionCreate()
{
$model=new Wsmembersdetails;
$model->MemberShipID = $this->_member->MemberShipID;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Wsmembersdetails']))
{
$model->attributes=$_POST['Wsmembersdetails'];
if($model->save())
$this->redirect(array('view','id'=>$model->CompanyID));
}
$this->render('create',array(
'model'=>$model
));
}
I don’t know what’s wrong, did I miss something ?