Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in admin/controller/catalog/category.php #2970

Closed
mhcwebdesign opened this issue Apr 29, 2015 · 2 comments
Closed

Bug in admin/controller/catalog/category.php #2970

mhcwebdesign opened this issue Apr 29, 2015 · 2 comments

Comments

@mhcwebdesign
Copy link
Collaborator

For OpenCart 2.0.2.0 and 2.0.2.1_rc:

In method validateForm, the $this->error['warning'] should be set whenever there are form validation errors for posted form fields. At the moment, it only does it when there is a validation error for the $this->request->post['keyword'].

Suggested bugfix: Method validateForm should look like this:

    protected function validateForm() {
        if (!$this->user->hasPermission('modify', 'catalog/category')) {
            $this->error['warning'] = $this->language->get('error_permission');
        }

        foreach ($this->request->post['category_description'] as $language_id => $value) {
            if ((utf8_strlen($value['name']) < 2) || (utf8_strlen($value['name']) > 255)) {
                $this->error['name'][$language_id] = $this->language->get('error_name');
            }

            if ((utf8_strlen($value['meta_title']) < 3) || (utf8_strlen($value['meta_title']) > 255)) {
                $this->error['meta_title'][$language_id] = $this->language->get('error_meta_title');
            }
        }

        if (utf8_strlen($this->request->post['keyword']) > 0) {
            $this->load->model('catalog/url_alias');

            $url_alias_info = $this->model_catalog_url_alias->getUrlAlias($this->request->post['keyword']);

            if ($url_alias_info && isset($this->request->get['category_id']) && $url_alias_info['query'] != 'category_id=' . $this->request->get['category_id']) {
                $this->error['keyword'] = sprintf($this->language->get('error_keyword'));
            }

            if ($url_alias_info && !isset($this->request->get['category_id'])) {
                $this->error['keyword'] = sprintf($this->language->get('error_keyword'));
            }
        }

        if ($this->error && !isset($this->error['warning'])) {
            $this->error['warning'] = $this->language->get('error_warning');
        }

        return !$this->error;
    }
@danielkerr
Copy link
Member

it also does this message when you have not filled in the category name

@mhcwebdesign
Copy link
Collaborator Author

Daniel, it should do the warning message, too, for missing category name. However, your code doesn't do it at the moment, please see my proposed bugfix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants