Wednesday, December 18, 2013

Yii beforeSave method

 function beforeSave() {
            
        if (parent::beforeSave()) {
            if($this->isNewRecord) {
            $this->password=md5($this->password);
             $this->createdate=date("Y-m-d, g:i a");
            }
        else {
            $this->modifydate=date("Y-m-d, g:i a");
          }
        
        }
        return true;
    }

Wednesday, December 4, 2013

yii ajaxLink

echo CHtml::ajaxLink(
  CHtml::image(Yii::app()->request->baseUrl.'/uploads/participants/thumbs/'.$model->picture,
      $model->name, array("style"=>"display:block; margin: 0 auto;height:90px;")),
  Yii::app()->createUrl( 'participants/participantdetails' ),
  array( 
    'type' => 'POST',
    'beforeSend' => "function( request )
                     { }",
    'success' => "function( data )
                  {
                   $('#idrr').html(data);
                  }",
    'data' => array( 'id' => $model->id)
  ),
  array(
    'href' => Yii::app()->createUrl( 'participants/participantdetails' ),
    'class' => 'dffclass'
  )
);