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


PHP Validation::forge方法代码示例

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


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

示例1: validate

 public static function validate($factory)
 {
     $val = Validation::forge($factory);
     $val->add_field('list_name', 'List Name', 'required|max_length[30]');
     $val->add_field('list_description', 'List Description', 'required|max_length[255]');
     return $val;
 }
开发者ID:ClixLtd,项目名称:pccupload,代码行数:7,代码来源:list.php

示例2: validate

 public static function validate($factory)
 {
     $val = Validation::forge($factory);
     $val->add_field('key', 'Name', 'required|max_length[255]');
     #$val->add_field('value', 'Name', 'required|max_length[255]');
     return $val;
 }
开发者ID:ksakuntanak,项目名称:buffohero_cms,代码行数:7,代码来源:filemanager.php

示例3: action_login

 public function action_login()
 {
     // Already logged in
     Auth::check() and Response::redirect('admin');
     $val = Validation::forge();
     if (Input::method() == 'POST') {
         $val->add('email', 'ユーザ名')->add_rule('required');
         $val->add('password', 'パスワード')->add_rule('required');
         if ($val->run()) {
             $auth = Auth::instance();
             // check the credentials. This assumes that you have the previous table created
             if (Auth::check() or $auth->login(Input::post('email'), Input::post('password'))) {
                 // credentials ok, go right in
                 if (Config::get('auth.driver', 'Simpleauth') == 'Ormauth') {
                     $current_user = Model\Auth_User::find_by_username(Auth::get_screen_name());
                 } else {
                     $current_user = Model_User::find_by_username(Auth::get_screen_name());
                 }
                 Session::set_flash('success', e('ようこそ、' . $current_user->username . 'さん'));
                 Response::redirect('admin');
             } else {
                 $this->template->set_global('login_error', '失敗しました');
             }
         }
     }
     $this->template->title = 'ログイン';
     $this->template->content = View::forge('admin/login', array('val' => $val), false);
 }
开发者ID:sato5603,项目名称:fuelphp1st-2nd,代码行数:28,代码来源:admin.php

示例4: action_edit

 public function action_edit()
 {
     $data['user'] = \Auth::get_profile_fields();
     $data['user']['email'] = \Auth::get_email();
     if (\Input::post()) {
         $user = \Input::post();
         $val = \Validation::forge();
         $val->add_field('fullname', 'fullname', 'required');
         if (\Input::post('password')) {
             $val->add_field('password', 'new password', 'required|min_length[3]|max_length[10]');
             $val->add_field('old_password', 'old password', 'required|min_length[3]|max_length[10]');
         }
         $val->add_field('email', 'email', 'required|valid_email');
         if ($val->run()) {
             if ($user['password'] === '') {
                 \Auth::update_user(array('email' => $user['email'], 'fullname' => $user['fullname']));
             } else {
                 \Auth::update_user(array('email' => $user['email'], 'password' => $user['password'], 'old_password' => $user['old_password'], 'fullname' => $user['fullname']));
             }
             \Session::set_flash('success', 'The profile has been successfully updated');
             \Response::redirect('/user');
         } else {
             // repopulate the username field and give some error text back to the view.
             $data['user'] = ['fullname' => $user['fullname'], 'email' => $user['email'], 'password' => $user['password'], 'old_password' => $user['old_password']];
             \Session::set_flash('error', $val->error());
         }
     }
     $data['actions'] = ['back' => ['label' => 'Back', 'url' => '/user']];
     $this->template->title = "Edit profile";
     $this->template->content = View::forge('user/edit.twig', $data);
 }
开发者ID:vano00,项目名称:jobs,代码行数:31,代码来源:user.php

示例5: action_set

 public function action_set()
 {
     $out['status'] = 'ok';
     $val = \Validation::forge();
     $val->add_field('m', 'element num', 'required|min_length[1]|max_length[5]');
     $val->add_field('val', 'value', 'max_length[250]');
     $val->add_field('mid', 'mac port id', 'required|min_length[1]|max_length[20]');
     if ($val->run()) {
         $new_val = $val->validated('val');
         if ($this->tmpl) {
             $macport = Model_Device_Template_Network_Mac::find($val->validated('mid'));
         } else {
             $macport = Model_Network_Mac::find($val->validated('mid'));
         }
         if ($macport) {
             switch ($val->validated('m')) {
                 case 3:
                     //pach panels
                     $macport->vlan = $new_val;
                     break;
             }
             $macport->save();
         }
         echo json_encode($out);
     }
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:26,代码来源:mac.php

示例6: action_login

 public function action_login()
 {
     if (Auth::check()) {
         Response::redirect('admin');
     }
     $val = Validation::forge();
     if (Input::method() == 'POST') {
         $val->add('email', 'Email or Username')->add_rule('required');
         $val->add('password', 'Password')->add_rule('required');
         if ($val->run()) {
             $auth = Auth::instance();
             // check the credentials. This assumes that you have the previous table created
             if (Auth::check() or $auth->login(Input::post('email'), Input::post('password'))) {
                 // credentials ok, go right in
                 $current_user = Model_User::find_by_username(Auth::get_screen_name());
                 Session::set_flash('success', e('Welcome, ' . $current_user->username));
                 Response::redirect('admin');
             } else {
                 $this->template->set_global('login_error', 'Fail');
             }
         }
     }
     $this->template->title = 'Login';
     $this->template->content = View::forge('admin/login', array('val' => $val), false);
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:25,代码来源:admin.php

示例7: validate

 /**
  * Validate Model fields
  * 
  * @param $factory = Validation name, if you want to have multiple validations
  */
 public static function validate($factory)
 {
     $val = \Validation::forge($factory);
     $val->add('email', 'Email')->add_rule('required')->add_rule('valid_email');
     $val->add('period', 'Period')->add_rule('required');
     return $val;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:12,代码来源:backup.php

示例8: action_login

 /**
  * Действие для авторизации пользователя
  */
 public function action_login()
 {
     // Already logged in
     \Auth::check() and \Response::redirect('admin/articles');
     $val = \Validation::forge();
     if (\Input::method() == 'POST') {
         $val->add('email', 'Логин')->add_rule('required');
         $val->add('password', 'Пароль')->add_rule('required');
         if ($val->run()) {
             $auth = \Auth::instance();
             // check the credentials. This assumes that you have the previous table created
             if (\Auth::check() or $auth->login(\Input::post('email'), \Input::post('password'))) {
                 // credentials ok, go right in
                 if (\Config::get('auth.driver', 'Simpleauth') == 'Ormauth') {
                     $current_user = \Model\Auth_User::find_by_username(\Auth::get_screen_name());
                 } else {
                     $current_user = \Model_User::find_by_username(\Auth::get_screen_name());
                 }
                 \Session::set_flash('success', 'Добро пожаловать, <b>' . $current_user->username . '</b>');
                 \Response::redirect('admin/articles');
             } else {
                 \Session::set_flash('error', 'Неверная комбинация логина и пароля.');
             }
         }
     }
     $this->template->title = 'Авторизация';
     $this->template->content = \View::forge('login', array('val' => $val), false);
 }
开发者ID:alexmon1989,项目名称:fcssadon.ru,代码行数:31,代码来源:admin.php

示例9: action_index

 public function action_index()
 {
     $errors = null;
     if (Input::post('confirm')) {
         foreach ($this->fields as $field) {
             Session::set_flash($field, Input::post($field));
         }
     }
     $val = Validation::forge();
     $val->add_callable('passwordvalidation');
     $val->add('firstname', 'Firstname')->add_rule('required');
     $val->add('lastname', 'Lastname')->add_rule('required');
     $val->add('email', 'Email address')->add_rule('required')->add_rule('valid_email');
     $val->add('sex', 'Gender')->add_rule('required');
     $val->add('password', 'password')->add_rule('required')->add_rule('password')->add_rule('min_length', 8);
     //$val->add('google_account','Gmail address')->add_rule('required');
     if (Security::check_token()) {
         if ($val->run()) {
             $user = Model_User::find("first", ["where" => [["email", Input::post("email", "")]]]);
             if ($user == null) {
                 Response::redirect("students/signup/confirm");
             } else {
                 $errors = ["This email is already in use."];
             }
         } else {
             $errors = $val->error();
         }
     }
     $data["errors"] = $errors;
     $view = View::forge("students/signup/index", $data);
     $this->template->content = $view;
 }
开发者ID:Trd-vandolph,项目名称:game-bootcamp,代码行数:32,代码来源:signup.php

示例10: create

 /**
  * Creates a new validation instance for order create.
  *
  * @param Model_Customer $customer The ordering customer.
  *
  * @return Validation
  */
 public static function create(Model_Customer $customer)
 {
     $validator = Validation::forge('order');
     $validator->add('products', 'Products')->add_rule('required')->add_rule(array('invalid_products' => function ($products) use($customer) {
         $ids = array_keys($products);
         foreach ($ids as $id) {
             if (!is_numeric($id)) {
                 return false;
             }
             $product_option = Service_Product_Option::find_one($id);
             if (!$product_option || $product_option->product->seller != $customer->seller) {
                 return false;
             }
         }
         return true;
     }));
     $validator->add('paymentmethod', 'Paymentmethod')->add_rule(array('invalid_paymentmethod' => function ($paymentmethod) use($customer) {
         if (!$paymentmethod) {
             return true;
         }
         $paymentmethod = Service_Customer_Paymentmethod::find_one($paymentmethod);
         if (!$paymentmethod || $paymentmethod->customer != $customer) {
             return false;
         }
         return true;
     }));
     return $validator;
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:35,代码来源:order.php

示例11: update

 /**
  * Creates a new validation instance for contact update.
  *
  * @return Validation
  */
 public static function update($type = 'customer')
 {
     $validator = Validation::forge('contact');
     $input = Input::param();
     if ($type == 'seller') {
         if (array_key_exists('company_name', $input)) {
             $validator->add('company_name', 'Company Name')->add_rule('trim')->add_rule('required');
         }
         if (array_key_exists('email', $input)) {
             $validator->add('email', 'Email')->add_rule('trim')->add_rule('valid_email')->add_rule('required');
         }
         $validator = self::add_optional_address_fields($validator);
     } elseif ($type == 'customer') {
         if (array_key_exists('first_name', $input)) {
             $validator->add('first_name', 'First Name')->add_rule('trim')->add_rule('required');
         }
         if (array_key_exists('last_name', $input)) {
             $validator->add('last_name', 'Last Name')->add_rule('trim')->add_rule('required');
         }
         if (array_key_exists('email', $input)) {
             $validator->add('email', 'Email')->add_rule('trim')->add_rule('valid_email')->add_rule('required');
         }
         $validator = self::add_optional_address_fields($validator);
     } elseif ($type == 'paymentmethod') {
         $validator = self::add_required_address_fields($validator);
     }
     $validator = self::add_optional_fields($validator);
     return $validator;
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:34,代码来源:contact.php

示例12: action_index

 public function action_index()
 {
     $is_chenged = false;
     $data["password_error"] = "";
     if (Input::post("timezone", null) !== null and Security::check_token()) {
         $this->user->timezone = Input::post("timezone", "");
         $this->user->save();
         $is_chenged = true;
     }
     if (Input::post("need_reservation_email", null) !== null and Security::check_token()) {
         $this->user->need_reservation_email = Input::post("need_reservation_email", 1);
         $this->user->need_news_email = Input::post("need_news_email", 1);
         $this->user->save();
         $is_chenged = true;
     }
     if (Input::post("password", null) != null and Security::check_token()) {
         $val = Validation::forge();
         $val->add_callable('passwordvalidation');
         $val->add_field("password", Lang::get('forgotpassword.password'), "required|match_field[password2]|password");
         $val->add_field("password2", Lang::get('forgotpassword.password'), "required|match_field[password]|password");
         if ($val->run()) {
             $this->user->password = Auth::instance()->hash_password(Input::post('password', ""));
             $this->user->save();
             $is_chenged = true;
         } else {
             $data["password_error"] = "password does not matched.";
         }
     }
     $data["user"] = $this->user;
     $data["is_chenged"] = $is_chenged;
     $view = View::forge("teachers/setting", $data);
     $this->template->content = $view;
 }
开发者ID:Trd-vandolph,项目名称:game-bootcamp,代码行数:33,代码来源:setting.php

示例13: validate

 /**
  * Validate Model fields
  * 
  * @param $factory = Validation name, if you want to have multiple validations
  */
 public static function validate($factory)
 {
     $val = \Validation::forge($factory);
     $val->add('title', 'Title')->add_rule('required')->add_rule('min_length', 5)->add_rule('max_length', 255);
     $val->add('description', 'Description')->add_rule('required');
     return $val;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:12,代码来源:image.php

示例14: action_edit

 /**
  * News category edit
  * 
  * @access  public
  * @params  integer
  * @return  Response
  */
 public function action_edit($id = null)
 {
     $news_category = \News\Model_NewsCategory::check_authority($id);
     $val = \Validation::forge()->add_model($news_category);
     if (\Input::method() == 'POST') {
         \Util_security::check_csrf();
         try {
             // 識別名の変更がない場合は unique を確認しない
             if (trim(\Input::post('name')) == $news_category->name) {
                 $val->fieldset()->field('name')->delete_rule('unique');
             }
             if (!$val->run()) {
                 throw new \FuelException($val->show_errors());
             }
             $post = $val->validated();
             $news_category->name = $post['name'];
             $news_category->label = $post['label'];
             \DB::start_transaction();
             $news_category->save();
             \DB::commit_transaction();
             \Session::set_flash('message', sprintf('%sを%sしました。', term('news.category.view'), term('form.edit')));
             \Response::redirect('admin/news/category');
         } catch (\FuelException $e) {
             if (\DB::in_transaction()) {
                 \DB::rollback_transaction();
             }
             \Session::set_flash('error', $e->getMessage());
         }
     }
     $this->set_title_and_breadcrumbs(term('news.category.view', 'form.edit'), array('admin/news' => term('news.view', 'admin.view'), 'admin/news/category' => term('news.category.view')));
     $this->template->post_header = \View::forge('news/_parts/form_header');
     $this->template->post_footer = \View::forge('news/_parts/form_footer');
     $this->template->content = \View::forge('news/category/edit', array('val' => $val, 'news' => $news_category));
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:41,代码来源:category.php

示例15: validate

 public static function validate($factory)
 {
     $val = Validation::forge($factory);
     //$val->add_field('slug', 'Slug', 'required|max_length[255]');
     $val->add_field('name', 'name', 'required|max_length[255]');
     return $val;
 }
开发者ID:blueshift9,项目名称:pscms,代码行数:7,代码来源:category.php


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