示例#1
0
 public function initialize($entity = null, $options = null)
 {
     $select = new Select('parentId');
     $category = new Models\Category();
     $categories = $category->find(array("order" => "id DESC", "limit" => 100));
     $categoryArray = array('None');
     foreach ($categories as $key => $item) {
         $categoryArray[$item->id] = $item->categoryName;
     }
     $select->setOptions($categoryArray);
     $this->add($select);
 }
示例#2
0
 public function addCid()
 {
     if ($this->cid) {
         return $this->cid;
     }
     $category = new Models\Category();
     $categories = $category->find(array("order" => "id DESC", "limit" => 100));
     if ($categories) {
         $options = array('All Categories');
         foreach ($categories as $categoryitem) {
             $options[$categoryitem->id] = $categoryitem->categoryName;
         }
         $element = new Select('cid', $options);
     }
     $this->add($element);
     return $this->cid = $element;
 }
示例#3
0
 public function getCategories()
 {
     if ($this->categories) {
         return $this->categories;
     }
     $category = new Models\Category();
     $categories = $category->find(array("order" => "id DESC", "limit" => 100));
     $post = $this->getModel();
     $values = array();
     if ($post && $post->categories) {
         foreach ($post->categories as $categoryitem) {
             $values[] = $categoryitem->id;
         }
     }
     foreach ($categories as $key => $item) {
         $check = new Check('categories[]', array('value' => $item->id));
         if (in_array($item->id, $values)) {
             $check->setDefault($item->id);
         }
         $check->setLabel($item->categoryName);
         $this->categories[] = $check;
     }
     return $this->categories;
 }