当前位置: 首页>>代码示例>>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;未经允许,请勿转载。