Ejemplo n.º 1
0
 static function createForm($id, $action)
 {
     //创建表单及添加元素
     $form = new Form_Admin_Teatype($id, $action);
     $form->add(QForm::ELEMENT, 'name', array('_ui' => 'textbox', '_label' => '分类的名称', 'class' => 'txt', '_req' => true, '_tips' => '请输入茶叶分类的名字不要超过40个字符'))->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden'))->add(QForm::ELEMENT, 'parent_id', array('_ui' => 'admin_typelist', '_label' => '父级类名', 'class' => 'txt'))->addValidations(TeaType::meta());
     return $form;
 }
 /**
  *  删除茶叶栏目
  */
 function actionDelete()
 {
     //得到茶叶的id列表
     $typeIds = (int) $this->_context->id;
     if (!empty($typeIds)) {
         $teaType = TeaType::find('parent_id =?', $typeIds)->asArray()->getAll();
         if (!count($teaType)) {
             TeaType::meta()->destroyWhere('id = ?', $typeIds);
             return $this->_redirectMessage('删除茶叶类别成功', '如果你不做出选择系统将自动跳转', url('teatype/index'), 3);
         } else {
             return $this->_redirectMessage('删除茶叶类别失败,请先确定该类别没有子类!', '如果你不做出选择系统将自动跳转', url('teatype/index'), 3);
         }
     }
 }