php - yii ajaxrequest fires action, but doesn't save to database -


i have ajaxlink use delete (update) item with:

<?php echo chtml::ajaxlink('<img src="handig/ikoons/x_20x20px.png" width="20"/>',array("bedrijf/delete","id"=>$data->id),array(     'data' => array('verwijderen'=> ''),     "beforesend" => "js:function(){return confirm('weet je zeker dat je dit item wilt verwijderen?')}",     "type"=>"post")); ?> 

this link calls function in contoller:

public function actiondelete($id)     {         echo 'hier';         $model=$this->loadmodel($id);         if(isset($_post['verwijderen']))         {             echo '<br>in de post '.$id;             $model->verwijderd = 1;             $model->verwijderdatum = new cdbexpression('now()');              if($model->save())                 echo '<br>opgeslagen';         }     } 

using echo's can see post right passes on model->save(). doesn't happen. have model, or waht happening here?

model rules:

public function rules()     {         return array(             array ("sectorb, vprojecten, cpgebdatum, toelichting, verwijderdatum" , "safe"),              array('naam, adres, postcode, plaats, wijk, email, cpnaam, cpachternaam, cpemail, cpgebdatum,                  rechtspositie, werkgebied, krachten, hoe'                 ,'required','message'=>'{attribute} nog niet ingevuld!'),             array('email, cpemail','email'),             array('functie, wijk, cpgeslacht, rechtsvorm, rechtspositie, verwijderd', 'numerical', 'integeronly'=>true),             array('naam, adres, plaats, email, website, socialmedia, cpnaam, cpachternaam, cpemail', 'length', 'max'=>50),             array('afkorting, postcode', 'length', 'max'=>10),             array('telefoon, mobiel, cptelefoon, cpmobiel', 'length', 'max'=>25),             array('orgdoel, orgactiviteiten, orgonderdeel, anders', 'length', 'max'=>500),         );     }  

ok, wasn't rules before save function handle datetime. sometime datetime empty , still function has return true, wrote exeption that:

protected function beforesave ()     {         if($this->cpgebdatum != ''){             list($d, $m, $y) = explode('-', $this->cpgebdatum);             $mk=mktime(0, 0, 0, $m, $d, $y);             $this->cpgebdatum = date ('y-m-d', $mk);              return parent::beforesave ();         }else{             return true;         }     } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -