<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ## 表單字段驗證器 > 說明: 設置表單字段驗證器。在提交表單時,對預設驗證規則的表單字段數據進行驗證。在設定的驗證器中可以寫字段自定義的驗證方法,也可對表單字段數據進行進一步處理(handleData操作)。默認表單字段驗證器為 `\yunj\Validate` 方法:`fieldValidate($callable)` * 參數 **callable** (必須),例: ```php fieldValidate(function(){ return TestValidate(); }); ``` * 返回值:需為 `\yunj\Validate`或其子類的實例對象 * 驗證環境scene: * `submit`:表單提交時的驗證環境 > 示例: 添加一個產品數據:`序列號(sn)`、`名稱(name)`、`所屬商戶(mid)`... * 驗證器 ```php namespace app\demo\validate\product; final class Add extends \yunj\Validate { // 自定義驗證方法,校驗序列號唯一性 protected function snUnique($value,$rule = "",$data){ $isExist = Db::name("product")->where("sn","=",$value)->select(); if($isExist ) return "該序列號已存在"; return true; } protected function handleData(array $raw_data, $scene): array { $data = $raw_data; switch ($scene) { case "submit": // 校驗商戶有效性,并獲取商戶數據添加到驗證數據里 $merchant = Db::name("merchant")->where("id","=",$data["mid"])->select(); if(!$merchant ) throw_error_json("商戶數據錯誤"); $data["merchant_data"] = $merchant; break; } return $data; } } ``` * 表單構建器: ```php $builder=YF('general_example')->field(function($tab){ $field=[ 'sn'=>['title'=>'序列號','verify'=>'require|snUnique'], 'name'=>['title'=>'名稱','verify'=>'require|chsDash','desc'=>'只能輸入漢字'], 'mid'=>[ 'title'=>'商戶', 'type'=>'dropdown_search', 'verify'=>'require|positiveInteger', "multi"=>false, 'url'=>url('merchantOptions') ] ]; return $field; })->fieldValidate(function(){ return new \app\demo\validate\product\Add(); })->submit(function($data,$tab_data){ // 獲取展商數據 $merchant = $data["merchant_data"]; // 業務處理... }); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看