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


PHP ProductCategory::validate_create方法代碼示例

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


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

示例1: action_add

 public function action_add()
 {
     $data = array();
     if (Request::$method == "POST") {
         $cat = new ProductCategory();
         $root_id = $_POST['parent_id'];
         $post = $cat->validate_create($_POST);
         if ($post->check()) {
             $post = $post->as_array();
             $cat->user_id = Auth::instance()->get_user()->id;
             $cat->name = $post['name'];
             $cat->slug = $post['slug'];
             $cat->meta_keys = $post['meta_keys'];
             $cat->meta_desc = $post['meta_desc'];
             $cat->save();
             //rebuil tree
             if ($root_id == 0) {
                 // if no parent was selected, add/move this node to be a new root in the tree
                 $categoryTree = ProductCategory::bll()->getTree();
                 $categoryTree->createRoot($cat);
             } else {
                 $parent = ProductCategory::bll()->findOneBy('id', $root_id);
                 $cat->getNode()->insertAsLastChildOf($parent);
             }
             Message::success('Thêm mới danh mục sản phẩm thành công!');
             Request::instance()->redirect('/admin/productcategory/index');
         } else {
             $data['errors'] = $post->errors();
             $_POST = $post->as_array();
         }
     }
     $this->template->title = __('Thêm mới danh mục sản phẩm');
     $this->template->section_title = __('Thêm mới danh mục sản phẩm');
     $q = ProductCategory::bll()->createQuery();
     $q->addOrderBy('root_id asc')->addOrderBy('lft asc');
     //echo $q->getSqlQuery();
     $objects = $q->execute();
     ///$trees[0] = ' --- ROOT ---';
     foreach ($objects as $object) {
         $prefix = '|';
         if ($object['level'] == 0) {
             $prefix = null;
         }
         $trees[$object['id']] = $prefix . ' ' . str_repeat('- ', $object['level'] * 2) . $object['name'];
     }
     $data['trees'] = $trees;
     $this->template->content = View::factory('admin/product/category/cat_add', $data);
 }
開發者ID:abdul-baten,項目名稱:hbcms,代碼行數:48,代碼來源:productcategory.php


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