hi im new to yii…
can someone pls help me…
Im trying to programmatically increment a defined primary key to a model with contents from a view…but sadly, it doesnt save…
ur help is much appreciated
here is my code on the controller:
if(isset($_POST['Somain']))
{
$model->attributes=$_POST['Somain'];
$count = $model->countAllDocNoPattern($model->getAttribute('DocNo'));
$count1 = sprintf('%04d', $count);
$newDocNo = $model->getAttribute('DocNo') .'-'.$count1;
$model->setAttribute('DocNo',$newDocNo);
if($model->save()){
$this->redirect(array('update','id'=>$model->DocNo));
}
}