コード例 #1
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $model = new Ipaddress('search');
     $formModel = new Ipaddress();
     $model->unsetAttributes();
     if (isset($_GET['pageSize'])) {
         Yii::app()->user->setState('pageSize', (int) $_GET['pageSize']);
         unset($_GET['pageSize']);
     }
     if (isset($_GET['Ipaddress'])) {
         $model->attributes = $_GET['Ipaddress'];
     }
     if (isset($_POST['Ipaddress']) && isset($_POST['createNewIP'])) {
         $formModel->attributes = $_POST['Ipaddress'];
         if ($formModel->save()) {
             $formModel->unsetAttributes();
             Yii::app()->user->setFlash("success", "<strong>Success : </strong> {$model->ip_address} new IP address added. ");
         }
     } else {
         $formModel->ip_address = Yii::app()->request->getUserHostAddress();
     }
     $datasource = $model->search();
     $this->render('index', compact('datasource', 'model', 'formModel'));
 }
コード例 #2
0
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Ipaddress('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Ipaddress'])) {
         $model->attributes = $_GET['Ipaddress'];
     }
     $this->render('admin', array('model' => $model));
 }