当前位置: 首页>>代码示例>>PHP>>正文


PHP GUMP::errors方法代码示例

本文整理汇总了PHP中GUMP::errors方法的典型用法代码示例。如果您正苦于以下问题:PHP GUMP::errors方法的具体用法?PHP GUMP::errors怎么用?PHP GUMP::errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GUMP的用法示例。


在下文中一共展示了GUMP::errors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register_post

 public function register_post()
 {
     $gump = new GUMP();
     $form = $gump->sanitize($_POST);
     $gump->validation_rules(array("firstname" => "required|valid_name", "lastname" => "required|valid_name", "street" => "required|street_address", "zip" => "required|numeric,min_len=4", "city" => "required", "country" => "required", "email" => "required|valid_email", "password" => "required", "password_verify" => "required"));
     $validation = $gump->run($form);
     if ($validation === false) {
         $errors = $gump->errors();
         for ($i = 0; $i < count($errors); $i++) {
             $this->form[$errors[$i]["field"]]["error"] = true;
         }
     } else {
         if ($user = (new Login())->createLogin($form["email"], $form["password"], $form["company"], $form["firstname"], $form["lastname"], $form["street"], $form["zip"], $form["city"], $form["country"])) {
             $session = new \Base\Session();
             $session->set("user_id", $user->getId());
             (new Request())->redirect("dashboard");
         }
     }
     $this->assign("error_message", "E-Mail oder Passwort falsch.");
     $this->register();
 }
开发者ID:xama5,项目名称:uver-erp,代码行数:21,代码来源:Router.php

示例2: posts

 /**
  * Check if data as posted and validate
  * fields with rules specified in rules.yml
  * @param string $rule
  * @param array $unset
  * @return array
  */
 public function posts($rule = '', array $unset = [])
 {
     if (\Request::isPost()) {
         $results = ['valid' => false];
         /**
          * get all posts
          */
         $posts = \Request::post();
         /**
          * unset unused fields if
          * needed
          */
         if (sizeof($unset)) {
             foreach ($unset as $fields) {
                 unset($posts[$fields]);
             }
         }
         /**
          * get rules
          */
         $rules = $rule ? Config::get('rules.' . $rule) : [];
         /**
          * use GUMP library to validate
          * and sanitize fields
          */
         $validator = new \GUMP();
         $posts = $validator->sanitize($posts);
         $validator->validation_rules($rules);
         $validated = $validator->run($posts);
         /**
          * check validations result
          */
         if (!$validated) {
             $results['error'] = $validator->errors();
             $results['data'] = $posts;
         } else {
             $results['valid'] = true;
             $results['data'] = $posts;
         }
         return $results;
     }
     return [];
 }
开发者ID:rivomanana,项目名称:rv-slim-base,代码行数:50,代码来源:BaseController.php

示例3: processForm

function processForm($data, $user)
{
    $gump = new GUMP();
    $data = $gump->sanitize($data);
    $gump->validation_rules(array('user_target_name' => 'required', 'repair_post_id' => 'required|integer', 'repair_type_id' => 'required|integer', 'user_target_id' => 'required|integer', 'startdatetime' => 'required', 'enddatetime' => 'required', 'customer_car_gv_number' => 'required', 'customer_car_mileage' => 'integer', 'customer_car_name' => 'required', 'customer_car_vin' => 'required', 'customer_name' => 'required', 'customer_phone' => 'required', 'customer_id' => 'integer', 'customer_car_id' => 'integer', 'id' => 'integer', 'state' => 'required|integer'));
    $gump->filter_rules(array('user_target_name' => 'trim|sanitize_string', 'customer_car_gv_number' => 'trim|sanitize_string', 'customer_car_name' => 'trim|sanitize_string', 'customer_car_vin' => 'trim|sanitize_string', 'customer_name' => 'trim|sanitize_string', 'customer_phone' => 'trim|sanitize_string'));
    $customer_car_id = null;
    $customer_id = null;
    $validated_data = $gump->run($data);
    if ($validated_data) {
        $customer_car = null;
        $customer = null;
        // добавляем авто
        if (!isset($validated_data['customer_car_id'])) {
            $customer_car = new CustomerCar();
        } else {
            $customer_car = CustomerCar::retrieveByPK($validated_data['customer_car_id']);
        }
        $customer_car->gv_number = $validated_data["customer_car_gv_number"];
        $customer_car->mileage = $validated_data["customer_car_mileage"];
        $customer_car->name = $validated_data["customer_car_name"];
        $customer_car->vin = $validated_data["customer_car_vin"];
        try {
            $customer_car->save();
            $customer_car_id = $customer_car->id;
            Log::toDebug(["Save CustomerCar", $customer_car_id]);
        } catch (Exception $ex) {
            Log::toDebug("ERROR_SAVE_TO_DATABASE");
            return ["err" => "ERROR_SAVE_TO_DATABASE"];
        }
        // добавляем заказчика
        if (!isset($validated_data['customer_id'])) {
            $customer = new Customer();
        } else {
            $customer = Customer::retrieveByPK($validated_data['customer_id']);
        }
        $customer->name = $validated_data["customer_name"];
        $customer->phone = $validated_data["customer_phone"];
        try {
            $customer->save();
            $customer_id = $customer->id;
            Log::toDebug(["Save CustomerCar", $customer_id]);
        } catch (Exception $ex) {
            return ["err" => "ERROR_SAVE_TO_DATABASE"];
        }
        try {
            if (!isset($validated_data['id'])) {
                $new_event = new GreaseRatEvent();
            } else {
                $new_event = GreaseRatEvent::retrieveByPK($validated_data['id']);
            }
            $new_event->repair_post_id = $validated_data["repair_post_id"];
            $new_event->repair_type_id = $validated_data["repair_type_id"];
            if (isset($user)) {
                $new_event->user_owner_id = $user->id;
            }
            $new_event->user_target_id = $validated_data["user_target_id"];
            $new_event->state = $validated_data["state"];
            $new_event->customer_id = $customer_id;
            $new_event->customer_car_id = $customer_car_id;
            $new_event->startdatetime = $validated_data["startdatetime"];
            $new_event->enddatetime = $validated_data["enddatetime"];
            $new_event->save();
            Log::toDebug(["Save rat event", $new_event->id]);
            return ['event' => $new_event];
        } catch (Exception $ex) {
            return ["err" => "ERROR_SAVE_TO_DATABASE"];
        }
    } else {
        return ["err" => "VALIDATE_FORM_ERROR", "errors" => $gump->errors()];
    }
}
开发者ID:vugluskr86,项目名称:_autoservice,代码行数:72,代码来源:index.php


注:本文中的GUMP::errors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。