當前位置: 首頁>>代碼示例>>PHP>>正文


PHP client::has_errors方法代碼示例

本文整理匯總了PHP中client::has_errors方法的典型用法代碼示例。如果您正苦於以下問題:PHP client::has_errors方法的具體用法?PHP client::has_errors怎麽用?PHP client::has_errors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在client的用法示例。


在下文中一共展示了client::has_errors方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: contractor

 /**
  * Form for submitting Contractor hirings
  */
 public function contractor()
 {
     $hiring = new Hiring_Model($this->get_ldap());
     $this->select_lists['manager'] = hiring_forms::format_manager_list($hiring->manager_list());
     $this->select_lists['buddy'] = hiring_forms::format_manager_list($hiring->buddy_list());
     // allow only hire_type = 'Contractor'
     $this->select_lists['hire_type'] = array('Contractor' => 'Contractor');
     /**
      * track required fields with this array, Validator uses it and form helper
      * uses it to determine which fields to decorate as 'required' in the UI
      */
     $required_fields = array('contract_type', 'contractor_category', 'first_name', 'last_name', 'address', 'phone_number', 'email_address', 'start_date', 'end_date', 'pay_rate', 'payment_limit', 'manager', 'location', 'statement_of_work');
     $form = array('hire_type' => 'Contractor', 'contract_type' => '', 'contractor_category' => '', 'first_name' => '', 'last_name' => '', 'org_name' => '', 'address' => '', 'phone_number' => '', 'email_address' => '', 'start_date' => '', 'end_date' => '', 'pay_rate' => '', 'payment_limit' => '', 'manager' => '', 'buddy' => '', 'location' => '', 'location_other' => '', 'statement_of_work' => '', 'mail_needed' => '', 'default_username' => '', 'mail_alias' => '', 'mail_lists' => '', 'other_comments' => '');
     $errors = $form;
     if ($_POST) {
         hiring_forms::filter_disallowed_values($this->select_lists);
         $post = new Validation($_POST);
         $post->pre_filter('trim', true);
         $post->add_rules('start_date', 'valid::date');
         $post->add_rules('end_date', 'valid::date');
         $post->add_rules('email_address', 'valid::email');
         if ($this->input->post('mail_needed') == '1') {
             array_push($required_fields, 'location');
         }
         if ($this->input->post('location') == 'other') {
             array_push($required_fields, 'location_other');
         }
         // add all the required fields
         foreach ($required_fields as $required_field) {
             $post->add_rules($required_field, 'required');
         }
         if ($post->validate()) {
             // check for invilid
             $form = arr::overwrite($form, $post->as_array());
             $form = $this->build_supplemental_form_values($form, $hiring);
             $bugs_to_file = array(Bugzilla::BUG_NEWHIRE_SETUP, Bugzilla::BUG_HR_CONTRACTOR);
             if ($form['mail_needed']) {
                 $bugs_to_file[] = Bugzilla::BUG_EMAIL_SETUP;
             }
             // File the appropriate Bugs
             $this->file_these($bugs_to_file, $form);
             // Send Buddy Email
             if (!empty($form['buddy'])) {
                 $this->notify_buddy($form, $hiring);
             }
             if (!client::has_errors()) {
                 url::redirect('hiring/contractor');
             }
         } else {
             $form = arr::overwrite($form, $post->as_array());
             client::validation_results(arr::overwrite($errors, $post->errors('hiring_contractor_form_validations')));
             client::messageSend("There were errors in some fields", E_USER_WARNING);
         }
     }
     // the UI used client to determine which fields to decorate as 'required'
     form::required_fields($required_fields);
     $this->template->js_extra = html::script(array('media/js/jquery.autocomplete.min.js'), false);
     $this->template->css_extra = html::stylesheet(array('media/css/jquery.autocomplete.css'), array('screen'));
     $this->template->title = 'Hiring::Contractor';
     $this->template->content = new View('pages/hiring_contractor');
     $this->template->content->form = $form;
     $this->template->content->lists = $this->select_lists;
 }
開發者ID:samkeen,項目名稱:workermgmt-k,代碼行數:66,代碼來源:hiring.php


注:本文中的client::has_errors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。