public function actionNewdestination() { if (isset($_POST['Destination'])) { $obj = new Destination(); $obj->attributes = $_POST['Destination']; if ($obj->validate()) { if ($obj->country == "0") { $obj->country = null; } if ($obj->country == "") { $obj->country = null; } if ($obj->state == "0") { $obj->state = null; } if ($obj->state == "") { $obj->state = null; } if ($obj->save()) { echo "success"; } else { echo print_r($obj->getErrors, true); } } else { echo print_r($obj->getErrors, true); } } }