当前位置: 首页>>代码示例>>PHP>>正文


PHP FormUtil::getValidationErrors方法代码示例

本文整理汇总了PHP中FormUtil::getValidationErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP FormUtil::getValidationErrors方法的具体用法?PHP FormUtil::getValidationErrors怎么用?PHP FormUtil::getValidationErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormUtil的用法示例。


在下文中一共展示了FormUtil::getValidationErrors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit

    public function edit($args = array())
    {
        $this->checkAjaxToken();

        $mode = $this->request->request->get('mode', 'new');
        $accessLevel = $mode == 'edit' ? ACCESS_EDIT : ACCESS_ADD;
        $this->throwForbiddenUnless(SecurityUtil::checkPermission('Categories::', '::', $accessLevel));

        $cid = isset($args['cid']) ? $args['cid'] : $this->request->request->get('cid', 0);
        $parent = isset($args['parent']) ? $args['parent'] : $this->request->request->get('parent', 1);
        $validationErrors = FormUtil::getValidationErrors();
        $editCat = '';

        $languages = ZLanguage::getInstalledLanguages();

        if ($validationErrors) {
            $category = new Categories_DBObject_Category(DBObject::GET_FROM_VALIDATION_FAILED); // need this for validation info
            $editCat = $category->get();
            $validationErrors = $validationErrors['category'];
        } else {
            // indicates that we're editing
            if ($mode == 'edit') {
                if (!$cid) {
                    return new Zikula_Response_Ajax_BadData($this->__('Error! Cannot determine valid \'cid\' for edit mode in \'Categories_admin_edit\'.'));
                }
                $category = new Categories_DBObject_Category();
                $editCat = $category->select($cid);
                $this->throwNotFoundUnless($editCat, $this->__('Sorry! No such item found.'));
            } else {
                // someone just pressen 'new' -> populate defaults
                $category = new Categories_DBObject_Category(); // need this for validation info
                $editCat['sort_value'] = '0';
                $editCat['parent_id'] = $parent;
            }
        }

        $attributes = isset($editCat['__ATTRIBUTES__']) ? $editCat['__ATTRIBUTES__'] : array();

        Zikula_AbstractController::configureView();
        $this->view->setCaching(Zikula_View::CACHE_DISABLED);

        $this->view->assign('mode', $mode)
            ->assign('category', $editCat)
            ->assign('attributes', $attributes)
            ->assign('languages', $languages)
            ->assign('validation', $category->_objValidation);

        $result = array(
            'action' => $mode == 'new' ? 'add' : 'edit',
            'result' => $this->view->fetch('categories_adminajax_edit.tpl'),
            'validationErrors' => $validationErrors
        );
        if ($validationErrors) {
            return new Zikula_Response_Ajax_BadData($validationErrors, $result);
        }

        return new Zikula_Response_Ajax($result);
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:58,代码来源:Ajax.php

示例2: edit

    /**
     * edit category
     */
    public function edit()
    {
        $cid = FormUtil::getPassedValue('cid', 0);
        $root_id = FormUtil::getPassedValue('dr', 1);
        $mode = FormUtil::getPassedValue('mode', 'new');
        $allCats = '';
        $editCat = '';

        $languages = ZLanguage::getInstalledLanguages();

        // indicates that we're editing
        if ($mode == 'edit') {
            if (!SecurityUtil::checkPermission('Categories::category', "::", ACCESS_ADMIN)) {
                return LogUtil::registerPermissionError();
            }

            if (!$cid) {
                return LogUtil::registerError($this->__('Error! Cannot determine valid \'cid\' for edit mode in \'Categories_admin_edit\'.'));
            }

            $category = new Categories_DBObject_Category();
            $editCat = $category->select($cid);
            if ($editCat == false) {
                return LogUtil::registerError($this->__('Sorry! No such item found.'), 404);
            }
        } else {
            // new category creation
            if (!SecurityUtil::checkPermission('Categories::category', '::', ACCESS_ADD)) {
                return LogUtil::registerPermissionError();
            }

            // since we inherit the domain settings from the parent, we get
            // the inherited (and merged) object from session
            if (isset($_SESSION['newCategory']) && $_SESSION['newCategory']) {
                $editCat = $_SESSION['newCategory'];
                unset($_SESSION['newCategory']);
                $category = new Categories_DBObject_Category(); // need this for validation info
            }
            // if we're back from validation get the object from input
            elseif (FormUtil::getValidationErrors()) {
                $category = new Categories_DBObject_Category(DBObject::GET_FROM_VALIDATION_FAILED); // need this for validation info
                $editCat = $category->get();
            }
            // someone just pressen 'new' -> populate defaults
            else {
                $category = new Categories_DBObject_Category(); // need this for validation info
                $editCat['sort_value'] = '0';
            }
        }

        $reloadOnCatChange = ($mode != 'edit');
        $allCats = CategoryUtil::getSubCategories($root_id, true, true, true, false, true);

        // now remove the categories which are below $editCat ...
        // you should not be able to set these as a parent category as it creates a circular hierarchy (see bug #4992)
        if (isset($editCat['ipath'])) {
            $cSlashEdit = StringUtil::countInstances($editCat['ipath'], '/');
            foreach ($allCats as $k => $v) {
                $cSlashCat = StringUtil::countInstances($v['ipath'], '/');
                if ($cSlashCat >= $cSlashEdit && strpos($v['ipath'], $editCat['ipath']) !== false) {
                    unset($allCats[$k]);
                }
            }
        }

        $selector = CategoryUtil::getSelector_Categories($allCats, 'id', (isset($editCat['parent_id']) ? $editCat['parent_id'] : 0), 'category[parent_id]', isset($defaultValue) ? $defaultValue : null, null, $reloadOnCatChange);

        $attributes = isset($editCat['__ATTRIBUTES__']) ? $editCat['__ATTRIBUTES__'] : array();

        $this->view->assign('mode', $mode)
                ->assign('category', $editCat)
                ->assign('attributes', $attributes)
                ->assign('languages', $languages)
                ->assign('categorySelector', $selector)
                ->assign('validation', $category->_objValidation);

        if ($mode == 'edit') {
            $this->view->assign('haveSubcategories', CategoryUtil::haveDirectSubcategories($cid))
                    ->assign('haveLeafSubcategories', CategoryUtil::haveDirectSubcategories($cid, false, true));
        }

        return $this->view->fetch('categories_admin_edit.tpl');
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:86,代码来源:Admin.php


注:本文中的FormUtil::getValidationErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。