コード例 #1
0
ファイル: LayoutTab.php プロジェクト: vigm/advancedMD
 public function hasErrors(Result $errors)
 {
     if ($errors->isValid()) {
         return FALSE;
     }
     foreach ($this->fields as $field) {
         if ($errors->hasErrors($field->getName())) {
             return TRUE;
         }
     }
     return FALSE;
 }
コード例 #2
0
ファイル: Routes.php プロジェクト: vigm/advancedMD
 public function update()
 {
     if (empty($_POST)) {
         ee()->functions->redirect($this->base_url);
     }
     $errors = new ValidationResult();
     $templates = ee()->api->get('Template')->with('TemplateGroup')->with('TemplateRoute')->filter('site_id', ee()->config->item('site_id'))->order('TemplateRoute.order', 'asc')->order('TemplateGroup.group_name', 'asc')->order('template_name', 'asc')->all();
     $submitted = ee()->input->post('routes');
     $order = array_keys($submitted);
     foreach ($templates as $template) {
         $id = $template->template_id;
         $submitted[$id]['route'] = trim($submitted[$id]['route']);
         if (!$template->TemplateRoute) {
             $template->TemplateRoute = ee('Model')->make('TemplateRoute');
         }
         $route = $template->TemplateRoute;
         if (empty($submitted[$id]['route'])) {
             $template->TemplateRoute = NULL;
             continue;
         }
         $route->route_required = $submitted[$id]['required'] != 'n';
         $route->route = $submitted[$id]['route'];
         $route->order = array_search($id, $order);
         $result = $route->validate();
         if ($result->isNotValid()) {
             foreach ($result->getFailed() as $field => $rules) {
                 foreach ($rules as $rule) {
                     $errors->addFailed("routes[{$id}][route]", $rule);
                 }
             }
         }
     }
     if ($errors->isValid()) {
         $templates->save();
         ee('CP/Alert')->makeInline()->asSuccess()->withTitle(lang('template_routes_saved'))->addToBody(lang('template_routes_saved_desc'))->defer();
         ee()->functions->redirect($this->base_url);
     } else {
         ee()->load->helper('html_helper');
         ee('CP/Alert')->makeInline()->asIssue()->withTitle(lang('template_routes_not_saved'))->addToBody(lang('template_routes_not_saved_desc'))->now();
         $this->index($templates, $errors);
     }
 }